summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/jsgen.nim2
-rw-r--r--tests/js/timplicit_nodecl.nim13
-rw-r--r--tests/js/tvarargs.nim2
3 files changed, 15 insertions, 2 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index 34d78ea7c..29a72c86e 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -1528,7 +1528,7 @@ proc genVarStmt(p: PProc, n: PNode) =
         assert(a.kind == nkIdentDefs)
         assert(a.sons[0].kind == nkSym)
         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)
           genVarInit(p, v, a.sons[2])
 
diff --git a/tests/js/timplicit_nodecl.nim b/tests/js/timplicit_nodecl.nim
new file mode 100644
index 000000000..79a921815
--- /dev/null
+++ b/tests/js/timplicit_nodecl.nim
@@ -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
diff --git a/tests/js/tvarargs.nim b/tests/js/tvarargs.nim
index e2366d7a9..2ddb421f8 100644
--- a/tests/js/tvarargs.nim
+++ b/tests/js/tvarargs.nim
@@ -6,7 +6,7 @@ type
     log*: proc() {.nimcall varargs.}
   Console = ref ConsoleObj
 
-var console* {.importc nodecl.}: Console
+var console* {.importc.}: Console
 
 when isMainModule:
   console.log "Hello, world"