mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-31 19:03:42 +00:00
Compare commits
5 Commits
version-2-
...
pr_mumu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c1a2f0ab7 | ||
|
|
1124bb88f8 | ||
|
|
b6d94353c0 | ||
|
|
85d5fef236 | ||
|
|
bcd4cb1201 |
@@ -2715,9 +2715,13 @@ proc semNimvmBranch(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
oldNotes = c.config.notes
|
||||
oldWarningAsErrors = c.config.warningAsErrors
|
||||
oldFeatures = c.features
|
||||
|
||||
# Both branches are checked, but their declarations cannot affect later code.
|
||||
c.openShadowScope()
|
||||
try:
|
||||
result = semExpr(c, n, flags)
|
||||
finally:
|
||||
c.closeScope()
|
||||
c.optionStack = oldOptionStack
|
||||
c.config.options = oldOptions
|
||||
c.config.notes = oldNotes
|
||||
|
||||
@@ -63,7 +63,7 @@ proc foo2 =
|
||||
discard
|
||||
else:
|
||||
let x = 1
|
||||
doAssert x == 1
|
||||
doAssert not declared(x)
|
||||
|
||||
when false:
|
||||
discard
|
||||
|
||||
9
tests/vm/t26048.nim
Normal file
9
tests/vm/t26048.nim
Normal file
@@ -0,0 +1,9 @@
|
||||
# issue #26048, `$` declarations must not leak from `when nimvm`
|
||||
|
||||
type U = object
|
||||
|
||||
when nimvm:
|
||||
proc `$`(_: U): string = "s"
|
||||
|
||||
var n: U
|
||||
doAssert $n != "s"
|
||||
12
tests/vm/twhennimvmscope1.nim
Normal file
12
tests/vm/twhennimvmscope1.nim
Normal file
@@ -0,0 +1,12 @@
|
||||
# issue #23687
|
||||
|
||||
when nimvm:
|
||||
proc mytest(a: int) =
|
||||
echo a
|
||||
else:
|
||||
template mytest(a: int) =
|
||||
echo a + 42
|
||||
|
||||
proc xxx() =
|
||||
mytest(100) #[tt.Error
|
||||
^ undeclared identifier: 'mytest']#
|
||||
13
tests/vm/twhennimvmscope2.nim
Normal file
13
tests/vm/twhennimvmscope2.nim
Normal file
@@ -0,0 +1,13 @@
|
||||
# issue #23688
|
||||
|
||||
when nimvm:
|
||||
proc mytest(a: int) =
|
||||
echo a
|
||||
else:
|
||||
template mytest(a: untyped) =
|
||||
echo a + 42
|
||||
|
||||
proc xxx() =
|
||||
mytest(100) #[tt.Error
|
||||
^ undeclared identifier: 'mytest']#
|
||||
xxx()
|
||||
10
tests/vm/twhennimvmscope3.nim
Normal file
10
tests/vm/twhennimvmscope3.nim
Normal file
@@ -0,0 +1,10 @@
|
||||
# issue #13450, example 3
|
||||
|
||||
proc bar() =
|
||||
when nimvm:
|
||||
let y = 1
|
||||
else:
|
||||
let y = 2
|
||||
discard y #[tt.Error
|
||||
^ undeclared identifier: 'y']#
|
||||
bar()
|
||||
16
tests/whenstmt/t26044.nim
Normal file
16
tests/whenstmt/t26044.nim
Normal file
@@ -0,0 +1,16 @@
|
||||
# issue #26044
|
||||
|
||||
discard """
|
||||
cmd: "nim check --hints:off --warnings:off $file"
|
||||
action: reject
|
||||
nimout: '''
|
||||
t26044.nim(15, 11) Error: undeclared identifier: 'g'
|
||||
t26044.nim(15, 11) Error: expression 'g' has no type (or is ambiguous)
|
||||
'''
|
||||
"""
|
||||
|
||||
proc p =
|
||||
when nimvm:
|
||||
var g: int
|
||||
discard g
|
||||
p()
|
||||
Reference in New Issue
Block a user