diff --git a/tests/misc/trfc_276.nim b/tests/misc/trfc_276.nim index c965a2c3b663..daf93521f623 100644 --- a/tests/misc/trfc_276.nim +++ b/tests/misc/trfc_276.nim @@ -7,7 +7,7 @@ proc test1 = doAssert a == 2 test1() -static: +static: # bug #10938 for i in '1' .. '2': var s: set[char] doAssert s == {} @@ -41,13 +41,12 @@ block: const foo = cast[Fn](0) -block: +block: # bug #13918 const test = block: var s = "" for i in 1 .. 5: var arr: array[3, int] var val: int - # echo arr, " ", val s.add $arr & " " & $val for j in 0 ..< len(arr): arr[j] = i @@ -55,13 +54,61 @@ block: s doAssert test == "[0, 0, 0] 0[0, 0, 0] 0[0, 0, 0] 0[0, 0, 0] 0[0, 0, 0] 0" -block: +block: # bug #13312 static: for _ in 0 ..< 3: var s: string s.add("foo") assert s == "foo" +block: # bug #13887 + static: # https://github.com/nim-lang/Nim/issues/13887#issuecomment-655829572 + var x = 5 + var y = addr(x) + y[] += 10 + doAssert x == y[] + + block: # Example 1 + template fun() = + var s = @[10,11,12] + let z = s[0].addr + doAssert z[] == 10 + z[] = 100 + doAssert z[] == 100 + doAssert s[0] == 100 # was failing here + static: fun() # was failing here + fun() # was working + + block: # Example 2 + template fun() = + var s = @[10,11,12] + let a1 = cast[int](s[0].addr) # 4323682360 + let z = s[0].addr + let a2 = cast[int](z) # 10 => BUG + doAssert a1 == a2 + static: fun() # fails + + block: # Example 3 + template fun() = + var s = @[10.1,11.2,12.3] + let a1 = cast[int](s[0].addr) + let z = s[0].addr + let a2 = cast[int](z) + static: fun() + +block: # bug #12172 + const a = block: + var test: array[5, string] + test + proc test = + const a2 = block: + var test: array[5, string] # was error here + test + proc test2 = + const a3 = block: + let i = 0 # Error here too + i + when false: # xxx this doesn't work yet block: