fixes #3804
This commit is contained in:
parent
cb3a38afa2
commit
86e79f5cec
3 changed files with 33 additions and 1 deletions
28
tests/vm/twrong_concat.nim
Normal file
28
tests/vm/twrong_concat.nim
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
discard """
|
||||
output: '''success'''
|
||||
"""
|
||||
|
||||
# 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
|
||||
assert(objs[0].field == "hello") # fails, because (objs[0].field == "hello bug") - mutated!
|
||||
|
||||
echo "success"
|
||||
Loading…
Add table
Add a link
Reference in a new issue