parent
5bed7d282a
commit
23fd098428
2 changed files with 17 additions and 1 deletions
|
|
@ -435,8 +435,8 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
of nkLetSection: semTemplSomeDecl(c, n, skLet)
|
of nkLetSection: semTemplSomeDecl(c, n, skLet)
|
||||||
of nkFormalParams:
|
of nkFormalParams:
|
||||||
checkMinSonsLen(n, 1, c.c.config)
|
checkMinSonsLen(n, 1, c.c.config)
|
||||||
n[0] = semTemplBody(c, n[0])
|
|
||||||
semTemplSomeDecl(c, n, skParam, 1)
|
semTemplSomeDecl(c, n, skParam, 1)
|
||||||
|
n[0] = semTemplBody(c, n[0])
|
||||||
of nkConstSection:
|
of nkConstSection:
|
||||||
for i in 0..<n.len:
|
for i in 0..<n.len:
|
||||||
var a = n[i]
|
var a = n[i]
|
||||||
|
|
|
||||||
16
tests/template/t17433.nim
Normal file
16
tests/template/t17433.nim
Normal 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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue