mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 08:54:53 +00:00
* Don't ignore return in semTemplateDef * Add test --------- Co-authored-by: SirOlaf <>
This commit is contained in:
@@ -674,6 +674,9 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
|
||||
# a template's parameters are not gensym'ed even if that was originally the
|
||||
# case as we determine whether it's a template parameter in the template
|
||||
# body by the absence of the sfGenSym flag:
|
||||
let retType = s.typ[0]
|
||||
if retType != nil and retType.kind != tyUntyped:
|
||||
allUntyped = false
|
||||
for i in 1..<s.typ.n.len:
|
||||
let param = s.typ.n[i].sym
|
||||
if param.name.id != ord(wUnderscore):
|
||||
|
||||
8
tests/template/t21532.nim
Normal file
8
tests/template/t21532.nim
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
template elementType(a: untyped): typedesc =
|
||||
typeof(block: (for ai in a: ai))
|
||||
|
||||
func fn[T](a: T) =
|
||||
doAssert elementType(a) is int
|
||||
|
||||
@[1,2,3].fn
|
||||
Reference in New Issue
Block a user