fixes #9864 [backport]
This commit is contained in:
parent
24106ade8f
commit
af815c3c18
2 changed files with 51 additions and 5 deletions
36
tests/macros/tescape_var_into_quotedo_as_const.nim
Normal file
36
tests/macros/tescape_var_into_quotedo_as_const.nim
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
discard """
|
||||
output: '''ok'''
|
||||
"""
|
||||
# bug #9864
|
||||
import macros, tables
|
||||
|
||||
proc bar(shOpt: Table[string, int]) = discard
|
||||
|
||||
macro dispatchGen(): untyped =
|
||||
var shOpt = initTable[string, int]()
|
||||
shOpt["foo"] = 10
|
||||
result = quote do:
|
||||
bar(`shOpt`)
|
||||
|
||||
dispatchGen()
|
||||
|
||||
type
|
||||
Foo = object
|
||||
data: seq[int]
|
||||
|
||||
proc barB(a: Foo) = discard
|
||||
|
||||
proc shOptB(): auto =
|
||||
var shOpt: Foo
|
||||
shOpt.data.setLen 1 # fails
|
||||
shOpt
|
||||
|
||||
macro dispatchGenB(): untyped =
|
||||
var shOpt = shOptB() # fails
|
||||
|
||||
result = quote do:
|
||||
barB(`shOpt`)
|
||||
|
||||
dispatchGenB()
|
||||
|
||||
echo "ok"
|
||||
Loading…
Add table
Add a link
Reference in a new issue