diff options
Diffstat (limited to 'tests/vm/twrong_concat.nim')
-rw-r--r-- | tests/vm/twrong_concat.nim | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/vm/twrong_concat.nim b/tests/vm/twrong_concat.nim new file mode 100644 index 000000000..59a10bdb9 --- /dev/null +++ b/tests/vm/twrong_concat.nim @@ -0,0 +1,22 @@ +# bug #3804 + +#import sequtils + +type AnObj = ref object + field: string + +#proc aBug(objs: seq[AnObj]) {.compileTime.} = +# discard objs.mapIt(it.field & " bug") + +proc sameBug(objs: seq[AnObj]) {.compileTime.} = + var strSeq = newSeq[string](objs.len) + strSeq[0] = objs[0].field & " bug" + +static: + var objs: seq[AnObj] = @[] + objs.add(AnObj(field: "hello")) + + sameBug(objs) + # sameBug(objs) + echo objs[0].field + doAssert(objs[0].field == "hello") # fails, because (objs[0].field == "hello bug") - mutated! |