diff options
author | LemonBoy <LemonBoy@users.noreply.github.com> | 2018-10-09 19:54:12 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-10-09 19:54:12 +0200 |
commit | ee14ace5d3f3ede9d47d60bd415e46a3fb121fb2 (patch) | |
tree | 73d7ec10f80d027971dc2bb10bc37c60bf33ea7c /tests/js/t6612.nim | |
parent | a3fb0a769c05f5a88a68c9762069cc0056207258 (diff) | |
download | Nim-ee14ace5d3f3ede9d47d60bd415e46a3fb121fb2.tar.gz |
Field checks for everybody (#8957)
* Field checks for JS backend * Clean nkCall nodes with no arguments Generating a nkEmpty in place of no arguments makes no sense form the AST point of view and also trips up the VM codegen. * Field checks for VM backend * Test case for #6612 This patchset fixes #6612 * Add test case for LHS double evaluation * Prevent LHS double-eval for JS backend * Prevent double evaluation in VM backend
Diffstat (limited to 'tests/js/t6612.nim')
-rw-r--r-- | tests/js/t6612.nim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/js/t6612.nim b/tests/js/t6612.nim new file mode 100644 index 000000000..232711c16 --- /dev/null +++ b/tests/js/t6612.nim @@ -0,0 +1,24 @@ +discard """ + action: "run" +""" + +proc fillWith(sq: var seq[int], n: int, unused: string) = + sq = @[n] + +type + Object = object of RootObj + case hasNums: bool + of true: + numbers: seq[int] + of false: + discard + always: seq[int] + +var obj = Object(hasNums: true) + +obj.always.fillWith(5, "unused") +doAssert obj.always == @[5] + +obj.numbers.fillWith(3, "unused") +doAssert obj.numbers == @[3] +doAssert obj.always == @[5] |