we need something better than warningAsError for effect handling viol… (#18796)

* we need something better than warningAsError for effect handling violations
This commit is contained in:
Andreas Rumpf 2021-09-04 08:18:00 +02:00 • committed by GitHub
commit ac7acd827c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 5 deletions

View file

@ -1420,7 +1420,7 @@ proc trackProc*(c: PContext; s: PSym, body: PNode) =
let p = s.ast[pragmasPos] let p = s.ast[pragmasPos]
let raisesSpec = effectSpec(p, wRaises) let raisesSpec = effectSpec(p, wRaises)
if not isNil(raisesSpec): if not isNil(raisesSpec):
checkRaisesSpec(g, emitWarnings, raisesSpec, t.exc, "can raise an unlisted exception: ", checkRaisesSpec(g, false, raisesSpec, t.exc, "can raise an unlisted exception: ",
hints=on, subtypeRelation, hintsArg=s.ast[0]) hints=on, subtypeRelation, hintsArg=s.ast[0])
# after the check, use the formal spec: # after the check, use the formal spec:
effects[exceptionEffects] = raisesSpec effects[exceptionEffects] = raisesSpec
@ -1429,7 +1429,7 @@ proc trackProc*(c: PContext; s: PSym, body: PNode) =
let tagsSpec = effectSpec(p, wTags) let tagsSpec = effectSpec(p, wTags)
if not isNil(tagsSpec): if not isNil(tagsSpec):
checkRaisesSpec(g, emitWarnings, tagsSpec, t.tags, "can have an unlisted effect: ", checkRaisesSpec(g, false, tagsSpec, t.tags, "can have an unlisted effect: ",
hints=off, subtypeRelation) hints=off, subtypeRelation)
# after the check, use the formal spec: # after the check, use the formal spec:
effects[tagEffects] = tagsSpec effects[tagEffects] = tagsSpec

View file

@ -2004,8 +2004,7 @@ elif hasAlloc:
inc(i) inc(i)
{.pop.} {.pop.}
proc echo*(x: varargs[typed, `$`]) {.magic: "Echo", tags: [WriteIOEffect], proc echo*(x: varargs[typed, `$`]) {.magic: "Echo", benign, sideEffect.}
benign, sideEffect.}
## Writes and flushes the parameters to the standard output. ## Writes and flushes the parameters to the standard output.
## ##
## Special built-in that takes a variable number of arguments. Each argument ## Special built-in that takes a variable number of arguments. Each argument

View file

@ -122,7 +122,7 @@ window.addEventListener('DOMContentLoaded', main);
<h1><a class="toc-backref" href="#12">Procs</a></h1> <h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item"> <dl class="item">
<div id="foo"> <div id="foo">
<dt><pre><span class="Keyword">proc</span> <a href="#foo"><span class="Identifier">foo</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span>.}</pre></dt> <dt><pre><span class="Keyword">proc</span> <a href="#foo"><span class="Identifier">foo</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd> <dd>
I do foo I do foo