fixes #9864 [backport]

This commit is contained in:
Araq 2018-12-05 10:58:18 +01:00
commit af815c3c18
2 changed files with 51 additions and 5 deletions

View 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"