diff options
author | LemonBoy <LemonBoy@users.noreply.github.com> | 2018-08-14 20:38:04 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-08-14 20:38:04 +0200 |
commit | c04404635b9efa2d6642887ca40f6222c54d9465 (patch) | |
tree | a00d4094e0085d021360c03e90aa0abd08b47f54 /tests/ccgbugs/topenarraycast.nim | |
parent | 9a7e6be62f6ee8818c6ef2f1504a6dd75774a616 (diff) | |
download | Nim-c04404635b9efa2d6642887ca40f6222c54d9465.tar.gz |
Fix unsound transform pass (#8633)
When a `var openArray[T]` function parameter goes trough the `transformAddrDeref` pass we may lose the `var` specifier, leading to nasty crashes at runtime.
Diffstat (limited to 'tests/ccgbugs/topenarraycast.nim')
-rw-r--r-- | tests/ccgbugs/topenarraycast.nim | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/ccgbugs/topenarraycast.nim b/tests/ccgbugs/topenarraycast.nim new file mode 100644 index 000000000..7d1bc8d03 --- /dev/null +++ b/tests/ccgbugs/topenarraycast.nim @@ -0,0 +1,8 @@ +proc foo[T](s: var openArray[T]): T = + for x in s: result += x + +proc bar(xyz: var seq[int]) = + doAssert 6 == (seq[int](xyz)).foo() + +var t = @[1,2,3] +bar(t) |