summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-04-29 09:09:38 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-04-29 09:09:49 +0200
commit55aa4c2689a59111a33ac479ca1a7b4f25df65ff (patch)
treee02aad3969bcdc0468081d01d910201b5eb9645e
parentd2b191dc738b46bbe81fca981355fb302e2885e1 (diff)
downloadNim-55aa4c2689a59111a33ac479ca1a7b4f25df65ff.tar.gz
fixes a critical PHP codegen bug
-rw-r--r--compiler/jsgen.nim19
1 files changed, 11 insertions, 8 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index 2da7db900..840a68e99 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -1243,13 +1243,16 @@ proc genPatternCall(p: PProc; n: PNode; pat: string; typ: PType;
 
 proc genInfixCall(p: PProc, n: PNode, r: var TCompRes) =
   # don't call '$' here for efficiency:
-  let pat = n.sons[0].sym.loc.r.data
-  internalAssert pat != nil
-  if pat.contains({'#', '(', '@'}):
-    var typ = skipTypes(n.sons[0].typ, abstractInst)
-    assert(typ.kind == tyProc)
-    genPatternCall(p, n, pat, typ, r)
-    return
+  let f = n[0].sym
+  if f.loc.r == nil: f.loc.r = mangleName(f, p.target)
+  if sfInfixCall in f.flags:
+    let pat = n.sons[0].sym.loc.r.data
+    internalAssert pat != nil
+    if pat.contains({'#', '(', '@'}):
+      var typ = skipTypes(n.sons[0].typ, abstractInst)
+      assert(typ.kind == tyProc)
+      genPatternCall(p, n, pat, typ, r)
+      return
   gen(p, n.sons[1], r)
   if r.typ == etyBaseIndex:
     if r.address == nil:
@@ -1266,7 +1269,7 @@ proc genInfixCall(p: PProc, n: PNode, r: var TCompRes) =
   genArgs(p, n, r, 2)
 
 proc genCall(p: PProc, n: PNode, r: var TCompRes) =
-  if thisParam(p, n.sons[0].typ) != nil:
+  if n.sons[0].kind == nkSym and thisParam(p, n.sons[0].typ) != nil:
     genInfixCall(p, n, r)
     return
   if p.target == targetPHP: