diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-11-20 00:53:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-19 17:53:25 +0100 |
commit | cecaf9c56b1240a44a4de837e03694a0c55ec379 (patch) | |
tree | be4434e4aaad0ea631d4093454b04128d6dab087 /tests/stdlib/tsugar.nim | |
parent | 5dafcf4957a225b1f015d131299e51735e7bb1d3 (diff) | |
download | Nim-cecaf9c56b1240a44a4de837e03694a0c55ec379.tar.gz |
fixes #22939; fixes #16890; push should but doesn't apply to importc … (#22944)
…var/let symbols fixes #22939 fixes #16890 Besides, it was applied to let/const/var with pragmas, now it is universally applied. ```nim {.push exportc.} proc foo = let bar = 12 echo bar {.pop.} ``` For example, the `bar` variable will be affected by `exportc`.
Diffstat (limited to 'tests/stdlib/tsugar.nim')
-rw-r--r-- | tests/stdlib/tsugar.nim | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/tests/stdlib/tsugar.nim b/tests/stdlib/tsugar.nim index c22a8608c..b9cbdd3e3 100644 --- a/tests/stdlib/tsugar.nim +++ b/tests/stdlib/tsugar.nim @@ -12,6 +12,23 @@ type # for capture test, ref #20679 FooCapture = ref object x: int +proc mainProc() = + block: # bug #16967 + var s = newSeq[proc (): int](5) + {.push exportc.} + proc bar() = + for i in 0 ..< s.len: + let foo = i + 1 + capture foo: + s[i] = proc(): int = foo + {.pop.} + + bar() + + for i, p in s.pairs: + let foo = i + 1 + doAssert p() == foo + template main() = block: # `=>` block: @@ -86,22 +103,6 @@ template main() = closure2 = () => (i, j) doAssert closure2() == (5, 3) - block: # bug #16967 - var s = newSeq[proc (): int](5) - {.push exportc.} - proc bar() = - for i in 0 ..< s.len: - let foo = i + 1 - capture foo: - s[i] = proc(): int = foo - {.pop.} - - bar() - - for i, p in s.pairs: - let foo = i + 1 - doAssert p() == foo - block: # issue #20679 # this should compile. Previously was broken as `var int` is an `nnkHiddenDeref` # which was not handled correctly @@ -299,6 +300,8 @@ template main() = test() + mainProc() + when not defined(js): # TODO fixme JS VM static: main() |