summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-11-06 21:55:13 +0100
committerAndreas Rumpf <rumpf_a@web.de>2018-11-06 21:55:13 +0100
commit73c306258b6e0e82cc977a8a5ce3e21c32ea8942 (patch)
treedb9e2a71ef0d61e0b0e1aa66509b55021a92cedf /compiler
parent24902394f713ba540e5c26dc5585fdc70ec11853 (diff)
downloadNim-73c306258b6e0e82cc977a8a5ce3e21c32ea8942.tar.gz
Nimscript: fixes #9246 [backport]
Diffstat (limited to 'compiler')
-rw-r--r--compiler/commands.nim1
-rw-r--r--compiler/main.nim1
-rw-r--r--compiler/nim.nim3
-rw-r--r--compiler/options.nim2
-rw-r--r--compiler/scriptconfig.nim1
5 files changed, 6 insertions, 2 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim
index 4346694f8..14141696f 100644
--- a/compiler/commands.nim
+++ b/compiler/commands.nim
@@ -776,6 +776,7 @@ proc processArgument*(pass: TCmdLinePass; p: OptParser;
     # nim filename.nims  is the same as "nim e filename.nims":
     if p.key.endswith(".nims"):
       config.command = "e"
+      incl(config.globalOptions, optWasNimscript)
       config.projectName = unixToNativePath(p.key)
       config.arguments = cmdLineRest(p)
       result = true
diff --git a/compiler/main.nim b/compiler/main.nim
index 6c8b0343e..853bfb4f6 100644
--- a/compiler/main.nim
+++ b/compiler/main.nim
@@ -265,6 +265,7 @@ proc mainCommand*(graph: ModuleGraph) =
     conf.cmd = cmdInteractive
     commandInteractive(graph)
   of "e":
+    incl conf.globalOptions, optWasNimscript
     commandEval(graph, mainCommandArg(conf))
   of "nop", "help":
     # prevent the "success" message:
diff --git a/compiler/nim.nim b/compiler/nim.nim
index 5f3347255..1c4dbd3be 100644
--- a/compiler/nim.nim
+++ b/compiler/nim.nim
@@ -54,7 +54,8 @@ proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) =
     of cmdArgument:
       if processArgument(pass, p, argsCount, config): break
   if pass == passCmd2:
-    if optRun notin config.globalOptions and config.arguments.len > 0 and config.command.normalize != "run":
+    if {optRun, optWasNimscript} * config.globalOptions == {} and
+        config.arguments.len > 0 and config.command.normalize notin ["run", "e"]:
       rawMessage(config, errGenerated, errArgsNeedRunOption)
 
 proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
diff --git a/compiler/options.nim b/compiler/options.nim
index 5f152ed49..4e8ae9d1f 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -45,7 +45,7 @@ type                          # please make sure we have under 32 options
   TOptions* = set[TOption]
   TGlobalOption* = enum       # **keep binary compatible**
     gloptNone, optForceFullMake,
-    optDeadCodeElimUnused,    # deprecated, always on
+    optWasNimscript,
     optListCmd, optCompileOnly, optNoLinking,
     optCDebug,                # turn on debugging information
     optGenDynLib,             # generate a dynamic library
diff --git a/compiler/scriptconfig.nim b/compiler/scriptconfig.nim
index f94533177..2040f9d21 100644
--- a/compiler/scriptconfig.nim
+++ b/compiler/scriptconfig.nim
@@ -123,6 +123,7 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
   cbconf setCommand:
     conf.command = a.getString 0
     let arg = a.getString 1
+    incl(conf.globalOptions, optWasNimscript)
     if arg.len > 0:
       conf.projectName = arg
       let path =