This commit is contained in:
Andreas Rumpf
2016-06-07 22:44:51 +02:00
parent dc33b7d7e9
commit e8faa214eb
2 changed files with 12 additions and 6 deletions

View File

@@ -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)

View File

@@ -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: