fixes #4600
This commit is contained in:
parent
e9e413552a
commit
55e86184a5
2 changed files with 15 additions and 6 deletions
|
|
@ -202,24 +202,25 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
if s != nil:
|
if s != nil:
|
||||||
incl(s.flags, sfUsed)
|
incl(s.flags, sfUsed)
|
||||||
mixinContext = s.magic in {mDefined, mDefinedInScope, mCompiles}
|
mixinContext = s.magic in {mDefined, mDefinedInScope, mCompiles}
|
||||||
let scOption = if s.name.id in ctx.toMixin: scForceOpen else: scOpen
|
let sc = symChoice(c, fn, s,
|
||||||
|
if s.name.id in ctx.toMixin: scForceOpen else: scOpen)
|
||||||
case s.kind
|
case s.kind
|
||||||
of skMacro:
|
of skMacro:
|
||||||
if macroToExpand(s):
|
if macroToExpand(s) and sc.safeLen <= 1:
|
||||||
styleCheckUse(fn.info, s)
|
styleCheckUse(fn.info, s)
|
||||||
result = semMacroExpr(c, n, n, s, {efNoSemCheck})
|
result = semMacroExpr(c, n, n, s, {efNoSemCheck})
|
||||||
result = semGenericStmt(c, result, flags, ctx)
|
result = semGenericStmt(c, result, flags, ctx)
|
||||||
else:
|
else:
|
||||||
n.sons[0] = symChoice(c, fn, s, scOption)
|
n.sons[0] = sc
|
||||||
result = n
|
result = n
|
||||||
mixinContext = true
|
mixinContext = true
|
||||||
of skTemplate:
|
of skTemplate:
|
||||||
if macroToExpand(s):
|
if macroToExpand(s) and sc.safeLen <= 1:
|
||||||
styleCheckUse(fn.info, s)
|
styleCheckUse(fn.info, s)
|
||||||
result = semTemplateExpr(c, n, s, {efNoSemCheck})
|
result = semTemplateExpr(c, n, s, {efNoSemCheck})
|
||||||
result = semGenericStmt(c, result, flags, ctx)
|
result = semGenericStmt(c, result, flags, ctx)
|
||||||
else:
|
else:
|
||||||
n.sons[0] = symChoice(c, fn, s, scOption)
|
n.sons[0] = sc
|
||||||
result = n
|
result = n
|
||||||
# BUGFIX: we must not return here, we need to do first phase of
|
# BUGFIX: we must not return here, we need to do first phase of
|
||||||
# symbol lookup. Also since templates and macros can do scope injections
|
# symbol lookup. Also since templates and macros can do scope injections
|
||||||
|
|
@ -230,7 +231,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
# Leave it as an identifier.
|
# Leave it as an identifier.
|
||||||
discard
|
discard
|
||||||
of skProc, skMethod, skIterator, skConverter, skModule:
|
of skProc, skMethod, skIterator, skConverter, skModule:
|
||||||
result.sons[0] = symChoice(c, fn, s, scOption)
|
result.sons[0] = sc
|
||||||
# do not check of 's.magic==mRoof' here because it might be some
|
# do not check of 's.magic==mRoof' here because it might be some
|
||||||
# other '^' but after overload resolution the proper one:
|
# other '^' but after overload resolution the proper one:
|
||||||
if ctx.bracketExpr != nil and n.len == 2 and s.name.s == "^":
|
if ctx.bracketExpr != nil and n.len == 2 and s.name.s == "^":
|
||||||
|
|
|
||||||
8
tests/generics/ttempl_in_generic.nim
Normal file
8
tests/generics/ttempl_in_generic.nim
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
# bug #4600
|
||||||
|
template foo(x: untyped): untyped = echo 1
|
||||||
|
template foo(x,y: untyped): untyped = echo 2
|
||||||
|
|
||||||
|
proc bar1[T](x: T) = foo(x)
|
||||||
|
proc bar2(x: float) = foo(x,x)
|
||||||
|
proc bar3[T](x: T) = foo(x,x)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue