mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
enforce void for nkWhileStmt [backport: 2.0] (#21170)
enforce void for nkWhileStmt
This commit is contained in:
@@ -105,7 +105,6 @@ proc semWhile(c: PContext, n: PNode; flags: TExprFlags): PNode =
|
||||
result.typ = n[1].typ
|
||||
elif implicitlyDiscardable(n[1]):
|
||||
result[1].typ = c.enforceVoidContext
|
||||
result.typ = c.enforceVoidContext
|
||||
|
||||
proc semProc(c: PContext, n: PNode): PNode
|
||||
|
||||
|
||||
@@ -99,3 +99,14 @@ block: # bug #13583
|
||||
let t = test
|
||||
doAssert t() == 12
|
||||
|
||||
block:
|
||||
proc bar(): string {.discardable.} =
|
||||
"15"
|
||||
|
||||
proc foo(): int =
|
||||
while true:
|
||||
raise newException(ValueError, "check")
|
||||
12
|
||||
|
||||
doAssertRaises(ValueError):
|
||||
doAssert foo() == 12
|
||||
|
||||
Reference in New Issue
Block a user