diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index ea58bb7dde..964752c169 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -981,7 +981,7 @@ proc genArrayAccess(p: PProc, n: PNode, r: var TCompRes) = r.res = "nimAt($1, $2)" % [r.address, r.res] elif ty.kind in {tyString, tyCString}: # XXX this needs to be more like substr($1,$2) - r.res = "ord($1[$2])" % [r.address, r.res] + r.res = "ord(@$1[$2])" % [r.address, r.res] else: r.res = "$1[$2]" % [r.address, r.res] else: diff --git a/lib/system.nim b/lib/system.nim index 5d6fcf8684..f584f75901 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2163,7 +2163,7 @@ proc `&` *[T](x: T, y: seq[T]): seq[T] {.noSideEffect.} = result[i+1] = y[i] when not defined(nimscript): - when not defined(JS): + when not defined(JS) or defined(nimphp): proc seqToPtr[T](x: seq[T]): pointer {.inline, nosideeffect.} = result = cast[pointer](x) else: diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index 2206837174..99997efe62 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -121,7 +121,10 @@ proc raiseException(e: ref Exception, ename: cstring) {. when not defined(noUnhandledHandler): if excHandler == 0: unhandledException(e) - asm "throw `e`;" + when defined(nimphp): + asm """throw new Exception($`e`["message"]);""" + else: + asm "throw `e`;" proc reraiseException() {.compilerproc, asmNoStackFrame.} = if lastJSError == nil: