revert getAst handling to not use overloading resolution

This commit is contained in:
Andreas Rumpf
2017-03-20 10:55:42 +01:00
parent 01b2728ec8
commit a6b0af539b
2 changed files with 19 additions and 2 deletions

View File

@@ -1607,8 +1607,25 @@ proc semExpandToAst(c: PContext, n: PNode): PNode =
for i in countup(1, macroCall.len-1):
#if macroCall.sons[0].typ.sons[i].kind != tyExpr:
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:
n.sons[1] = semOverloadedCall(c, macroCall, macroCall, {skTemplate, skMacro})
#n.sons[1] = semOverloadedCall(c, macroCall, macroCall, {skTemplate, skMacro})
else:
localError(n.info, "getAst takes a call, but got " & n.renderTree)
# Preserve the magic symbol in order to be handled in evals.nim

View File

@@ -1,5 +1,5 @@
discard """
errormsg: "type mismatch"
errormsg: "expected a template that takes 3 arguments"
line: 16
"""