made nodecl implicit for vars in the js backend. (#5297)
This commit is contained in:
parent
5e1bdb4d83
commit
d75760f5d3
3 changed files with 15 additions and 2 deletions
|
|
@ -1528,7 +1528,7 @@ proc genVarStmt(p: PProc, n: PNode) =
|
||||||
assert(a.kind == nkIdentDefs)
|
assert(a.kind == nkIdentDefs)
|
||||||
assert(a.sons[0].kind == nkSym)
|
assert(a.sons[0].kind == nkSym)
|
||||||
var v = a.sons[0].sym
|
var v = a.sons[0].sym
|
||||||
if lfNoDecl notin v.loc.flags:
|
if lfNoDecl notin v.loc.flags and sfImportc notin v.flags:
|
||||||
genLineDir(p, a)
|
genLineDir(p, a)
|
||||||
genVarInit(p, v, a.sons[2])
|
genVarInit(p, v, a.sons[2])
|
||||||
|
|
||||||
|
|
|
||||||
13
tests/js/timplicit_nodecl.nim
Normal file
13
tests/js/timplicit_nodecl.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
discard """
|
||||||
|
output: '''22
|
||||||
|
22'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
# test implicit nodecl
|
||||||
|
block:
|
||||||
|
{. emit: "var importMe = 22;" .}
|
||||||
|
var
|
||||||
|
a {. importc: "importMe" .}: int
|
||||||
|
importMe {. importc .}: int
|
||||||
|
echo a
|
||||||
|
echo importMe
|
||||||
|
|
@ -6,7 +6,7 @@ type
|
||||||
log*: proc() {.nimcall varargs.}
|
log*: proc() {.nimcall varargs.}
|
||||||
Console = ref ConsoleObj
|
Console = ref ConsoleObj
|
||||||
|
|
||||||
var console* {.importc nodecl.}: Console
|
var console* {.importc.}: Console
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
console.log "Hello, world"
|
console.log "Hello, world"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue