* fix: `var a{.foo.} = expr` inside templates
* add test
* improve tdecls test
* improve tests
* add failing test
* PRTEMP
* fixup
This commit is contained in:
parent
8540065754
commit
6c1bd4bb1c
5 changed files with 107 additions and 20 deletions
|
|
@ -1,6 +1,10 @@
|
|||
discard """
|
||||
targets: "c cpp js"
|
||||
"""
|
||||
|
||||
import std/decls
|
||||
|
||||
block:
|
||||
template fun() =
|
||||
var s = @[10,11,12]
|
||||
var a {.byaddr.} = s[0]
|
||||
a+=100
|
||||
|
|
@ -34,6 +38,13 @@ block:
|
|||
doAssert compiles(block:
|
||||
var b2 {.byaddr.}: int = s[2])
|
||||
|
||||
proc fun2() = fun()
|
||||
fun()
|
||||
fun2()
|
||||
static: fun2()
|
||||
when false: # pending bug #13887
|
||||
static: fun()
|
||||
|
||||
## We can define custom pragmas in user code
|
||||
template byUnsafeAddr(lhs, typ, expr) =
|
||||
when typ is type(nil):
|
||||
|
|
@ -68,3 +79,13 @@ block: # nkAccQuoted
|
|||
let a {.`cast`.} = s[0]
|
||||
doAssert a == "foo"
|
||||
doAssert a[0].unsafeAddr == s[0][0].unsafeAddr
|
||||
|
||||
block: # bug #15920
|
||||
template foo(lhs, typ, expr) =
|
||||
let lhs = expr
|
||||
proc fun1()=
|
||||
let a {.foo.} = 1
|
||||
template fun2()=
|
||||
let a {.foo.} = 1
|
||||
fun1() # ok
|
||||
fun2() # BUG
|
||||
|
|
|
|||
|
|
@ -27,6 +27,6 @@ since (99, 3):
|
|||
doAssert false
|
||||
|
||||
when false:
|
||||
# pending https://github.com/timotheecour/Nim/issues/129
|
||||
# pending bug #15920
|
||||
# Error: cannot attach a custom pragma to 'fun3'
|
||||
template fun3(): int {.since: (1, 3).} = 12
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue