revert getAst handling to not use overloading resolution
This commit is contained in:
parent
01b2728ec8
commit
a6b0af539b
2 changed files with 19 additions and 2 deletions
|
|
@ -1607,8 +1607,25 @@ proc semExpandToAst(c: PContext, n: PNode): PNode =
|
||||||
for i in countup(1, macroCall.len-1):
|
for i in countup(1, macroCall.len-1):
|
||||||
#if macroCall.sons[0].typ.sons[i].kind != tyExpr:
|
#if macroCall.sons[0].typ.sons[i].kind != tyExpr:
|
||||||
macroCall.sons[i] = semExprWithType(c, macroCall[i], {})
|
macroCall.sons[i] = semExprWithType(c, macroCall[i], {})
|
||||||
|
# performing overloading resolution here produces too serious regressions:
|
||||||
|
let headSymbol = macroCall[0]
|
||||||
|
var cands = 0
|
||||||
|
var cand: PSym = nil
|
||||||
|
var o: TOverloadIter
|
||||||
|
var symx = initOverloadIter(o, c, headSymbol)
|
||||||
|
while symx != nil:
|
||||||
|
if symx.kind in {skTemplate, skMacro} and symx.typ.len == macroCall.len:
|
||||||
|
cand = symx
|
||||||
|
inc cands
|
||||||
|
symx = nextOverloadIter(o, c, headSymbol)
|
||||||
|
if cands == 0:
|
||||||
|
localError(n.info, "expected a template that takes " & $(macroCall.len-1) & " arguments")
|
||||||
|
elif cands >= 2:
|
||||||
|
localError(n.info, "ambiguous symbol in 'getAst' context: " & $macroCall)
|
||||||
|
else:
|
||||||
|
macroCall.sons[0] = newSymNode(cand)
|
||||||
# we just perform overloading resolution here:
|
# we just perform overloading resolution here:
|
||||||
n.sons[1] = semOverloadedCall(c, macroCall, macroCall, {skTemplate, skMacro})
|
#n.sons[1] = semOverloadedCall(c, macroCall, macroCall, {skTemplate, skMacro})
|
||||||
else:
|
else:
|
||||||
localError(n.info, "getAst takes a call, but got " & n.renderTree)
|
localError(n.info, "getAst takes a call, but got " & n.renderTree)
|
||||||
# Preserve the magic symbol in order to be handled in evals.nim
|
# Preserve the magic symbol in order to be handled in evals.nim
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch"
|
errormsg: "expected a template that takes 3 arguments"
|
||||||
line: 16
|
line: 16
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue