Fixes #17433; gensym callDef return in templ body (#17445)

This commit is contained in:
Saem Ghani 2021-03-21 16:33:37 -07:00 • committed by GitHub
commit 23fd098428
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

16
tests/template/t17433.nim Normal file
View file

@ -0,0 +1,16 @@
# Inside template bodies, ensure return types referencing a param are replaced.
# This helps guarantee that return parameter analysis happens after argument
# analysis.
# bug #17433
from std/macros import expandMacros
proc bar(a: typedesc): a = default(a)
assert bar(float) == 0.0
assert bar(string) == ""
template main =
proc baz(a: typedesc): a = default(a)
assert baz(float) == 0.0
main()