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
parent cddf8ec6f6
commit ac7acd827c
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 raisesSpec = effectSpec(p, wRaises)
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])
# after the check, use the formal spec:
effects[exceptionEffects] = raisesSpec
@@ -1429,7 +1429,7 @@ proc trackProc*(c: PContext; s: PSym, body: PNode) =
let tagsSpec = effectSpec(p, wTags)
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)
# after the check, use the formal spec:
effects[tagEffects] = tagsSpec

View File

@@ -2004,8 +2004,7 @@ elif hasAlloc:
inc(i)
{.pop.}
proc echo*(x: varargs[typed, `$`]) {.magic: "Echo", tags: [WriteIOEffect],
benign, sideEffect.}
proc echo*(x: varargs[typed, `$`]) {.magic: "Echo", benign, sideEffect.}
## Writes and flushes the parameters to the standard output.
##
## 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>
<dl class="item">
<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>
I do foo