summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-06-07 22:44:51 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-06-07 22:46:12 +0200
commite8faa214eb563629ddca74c0eee3426a28d4fb3f (patch)
treecfac514006d6170a38620179c9b3ec96bea51c22 /compiler
parentdc33b7d7e925ce9b95c9800ed9ccbc0281949c01 (diff)
downloadNim-e8faa214eb563629ddca74c0eee3426a28d4fb3f.tar.gz
fixes #4295
Diffstat (limited to 'compiler')
-rw-r--r--compiler/magicsys.nim14
-rw-r--r--compiler/semmagic.nim4
2 files changed, 12 insertions, 6 deletions
diff --git a/compiler/magicsys.nim b/compiler/magicsys.nim
index 40e0728ae..13b365d04 100644
--- a/compiler/magicsys.nim
+++ b/compiler/magicsys.nim
@@ -41,11 +41,15 @@ proc getSysSym*(name: string): PSym =
 proc getSysMagic*(name: string, m: TMagic): PSym =
   var ti: TIdentIter
   let id = getIdent(name)
-  result = initIdentIter(ti, systemModule.tab, id)
-  while result != nil:
-    if result.kind == skStub: loadStub(result)
-    if result.magic == m: return result
-    result = nextIdentIter(ti, systemModule.tab)
+  var r = initIdentIter(ti, systemModule.tab, id)
+  while r != nil:
+    if r.kind == skStub: loadStub(r)
+    if r.magic == m:
+      # prefer the tyInt variant:
+      if r.typ.sons[0].kind == tyInt: return r
+      result = r
+    r = nextIdentIter(ti, systemModule.tab)
+  if result != nil: return result
   rawMessage(errSystemNeeds, name)
   result = newSym(skError, id, systemModule, systemModule.info)
   result.typ = newType(tyError, systemModule)
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim
index 1a70e4a12..1945d87eb 100644
--- a/compiler/semmagic.nim
+++ b/compiler/semmagic.nim
@@ -203,7 +203,9 @@ proc magicsAfterOverloadResolution(c: PContext, n: PNode,
         result = n.sons[1]
       else:
         result = newNodeIT(nkCall, n.info, getSysType(tyInt))
-        result.add newSymNode(getSysMagic("-", mSubI), n.info)
+        let subi = getSysMagic("-", mSubI)
+        #echo "got ", typeToString(subi.typ)
+        result.add newSymNode(subi, n.info)
         result.add lenExprB
         result.add n.sons[1]
   of mPlugin: