mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-24 00:05:25 +00:00
`len` could contain side effects and may result in different values when substituted twice in the template expansion. Instead, capture the result of substituting `len` once. closes: #21538
This commit is contained in:
committed by
GitHub
parent
285ea3c48e
commit
da7833c68b
@@ -388,6 +388,11 @@ block: # newSeqWith tests
|
||||
seq2D[0][1] = true
|
||||
doAssert seq2D == @[@[true, true], @[true, false], @[false, false], @[false, false]]
|
||||
|
||||
block: # bug #21538
|
||||
var x: seq[int] = @[2, 4]
|
||||
var y = newSeqWith(x.pop(), true)
|
||||
doAssert y == @[true, true, true, true]
|
||||
|
||||
block: # mapLiterals tests
|
||||
let x = mapLiterals([0.1, 1.2, 2.3, 3.4], int)
|
||||
doAssert x is array[4, int]
|
||||
|
||||
Reference in New Issue
Block a user