fixes #14900, this time for real, maybe (#14934)

This commit is contained in:
Andreas Rumpf 2020-07-08 14:47:14 +02:00 • committed by GitHub
commit 06d776a582
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 17 deletions

View file

@ -105,20 +105,14 @@ proc escapeCheck =
escapeCheck()
# bug #14900
template sortedByIt(seq1): untyped =
var result = seq1
result
proc seqsEqual(seq1, seq2: seq[string]): bool =
# works as a normal proc (if we would assign result inside)
# doesn't work as an expression
result = if false: # needed
false
else:
let a1 = seq1.sortedByIt()
let a2 = seq2.sortedByIt()
# echo a1 - works if you uncomment any of these
# echo a2
a1 == a2
proc seqsEqual(a, b: string): bool =
if false:
false
else:
(var result1 = a; result1) == (var result2 = b; result2)
echo seqsEqual(@["a", "b", "c"], @["a", "b", "c"])
# can be const or var too
let expected = "hello"
echo seqsEqual(expected, expected)