diff options
author | Araq <rumpf_a@web.de> | 2014-08-17 21:24:01 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-08-17 21:24:01 +0200 |
commit | e662013ee00c2ea8f80d2aff03965d789d38fd78 (patch) | |
tree | 62b4d553f07c088b8708ee10f540f1e173feaae7 /compiler | |
parent | 710cbe3f1f5947ec76e517fa9a4f679ec653eefd (diff) | |
parent | aa732881422ebd011871217dfe4713bf9dfebf90 (diff) | |
download | Nim-e662013ee00c2ea8f80d2aff03965d789d38fd78.tar.gz |
Merge branch 'devel' of https://github.com/Araq/Nimrod into devel
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/jsgen.nim | 15 | ||||
-rw-r--r-- | compiler/semcall.nim | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 96d8b3d11..72fe4ecc5 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -833,8 +833,8 @@ proc genSwap(p: PProc, n: PNode) = "local $1 = $2; $2 = $3; $3 = $1;$n", [ tmp, a.address, b.address]) tmp = tmp2 - appf(p.body, "var $1 = $2; $2 = $3; $3 = $1" | - "local $1 = $2; $2 = $3; $3 = $1", [tmp, a.res, b.res]) + appf(p.body, "var $1 = $2; $2 = $3; $3 = $1;" | + "local $1 = $2; $2 = $3; $3 = $1;", [tmp, a.res, b.res]) proc getFieldPosition(f: PNode): int = case f.kind @@ -881,14 +881,15 @@ proc genArrayAddr(p: PProc, n: PNode, r: var TCompRes) = a, b: TCompRes first: BiggestInt r.typ = etyBaseIndex - gen(p, n.sons[0], a) - gen(p, n.sons[1], b) + let m = if n.kind == nkHiddenAddr: n.sons[0] else: n + gen(p, m.sons[0], a) + gen(p, m.sons[1], b) internalAssert a.typ != etyBaseIndex and b.typ != etyBaseIndex r.address = a.res - var typ = skipTypes(n.sons[0].typ, abstractPtrs) + var typ = skipTypes(m.sons[0].typ, abstractPtrs) if typ.kind in {tyArray, tyArrayConstr}: first = firstOrd(typ.sons[0]) else: first = 0 - if optBoundsCheck in p.options and not isConstExpr(n.sons[1]): + if optBoundsCheck in p.options and not isConstExpr(m.sons[1]): useMagic(p, "chckIndx") r.res = ropef("chckIndx($1, $2, $3.length)-$2", [b.res, toRope(first), a.res]) @@ -1351,7 +1352,7 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) = of mEcho: genEcho(p, n, r) of mSlurp, mStaticExec: localError(n.info, errXMustBeCompileTime, n.sons[0].sym.name.s) - of mCopyStr: binaryExpr(p, n, r, "", "($1.slice($2,-1))") + of mCopyStr: binaryExpr(p, n, r, "", "($1.slice($2))") of mCopyStrLast: ternaryExpr(p, n, r, "", "($1.slice($2, ($3)+1).concat(0))") of mNewString: unaryExpr(p, n, r, "mnewString", "mnewString($1)") of mNewStringOfCap: unaryExpr(p, n, r, "mnewString", "mnewString(0)") diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 65a2d7ab8..927b23cf2 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -81,6 +81,8 @@ proc notFoundError*(c: PContext, n: PNode, errors: seq[string]) = if c.inCompilesContext > 0: # fail fast: globalError(n.info, errTypeMismatch, "") + if errors.len == 0: + localError(n.info, errExprXCannotBeCalled, n[0].renderTree) var result = msgKindToString(errTypeMismatch) add(result, describeArgs(c, n, 1)) add(result, ')') |