summary refs log tree commit diff stats
path: root/compiler/semexprs.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-03-20 10:55:42 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-03-20 10:56:15 +0100
commita6b0af539be81229e4d4b659f2e831d29c7f17b5 (patch)
tree8b2e396b1cf8ef76b3c3f026eecd09c91d3a1b64 /compiler/semexprs.nim
parent01b2728ec8a7830c0e034a482b47c030f99eeb49 (diff)
downloadNim-a6b0af539be81229e4d4b659f2e831d29c7f17b5.tar.gz
revert getAst handling to not use overloading resolution
Diffstat (limited to 'compiler/semexprs.nim')
-rw-r--r--compiler/semexprs.nim19
1 files changed, 18 insertions, 1 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index cf3fe57af..9c4d5bcd2 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -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