Skip to content

Commit

Permalink
add test for bug nim-lang#15464
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Nov 16, 2020
1 parent e569850 commit 1654ed0
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions tests/misc/taddr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,31 @@ block:
when false:
proc byLent2[T](a: T): lent type(a[0]) = a[0]

proc test15939() =
# bug #15939
template testStatic15464() = # bug #15464
proc access(s: var seq[char], i: int): var char = s[i]
proc access(s: var string, i: int): var char = s[i]
static:
var s = @['a', 'b', 'c']
access(s, 2) = 'C'
doAssert access(s, 2) == 'C'
static:
var s = "abc"
access(s, 2) = 'C'
doAssert access(s, 2) == 'C'

proc test15464() = # alternative bug #15464
proc access(s: var seq[char], i: int): var char = s[i]
proc access(s: var string, i: int): var char = s[i]
block:
var s = @['a', 'b', 'c']
access(s, 2) = 'C'
doAssert access(s, 2) == 'C'
block:
var s = "abc"
access(s, 2) = 'C'
doAssert access(s, 2) == 'C'

proc test15939() = # bug #15939
template fn(a) =
let pa = a[0].addr
doAssert pa != nil
Expand Down Expand Up @@ -165,7 +188,9 @@ proc test15939() =
when not defined(js): cstringTest()

template main =
test15464()
test15939()

testStatic15464()
main()
static: main()

0 comments on commit 1654ed0

Please sign in to comment.