summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-05-08 09:54:16 -0700
committerGitHub <noreply@github.com>2020-05-08 18:54:16 +0200
commit411be506a30a701ab30138c576e21bd15dfaffe4 (patch)
tree8328f1c7ac39395e748d5d691edf5f3bd4a6430e
parentce16115e790b4fcd6076d0d0f0024a11ce15a2b7 (diff)
downloadNim-411be506a30a701ab30138c576e21bd15dfaffe4.tar.gz
--hint:processing (+friends) is now supported and means `--hint:processing:on`, like all other bool flags (#14271)
-rw-r--r--changelog.md3
-rw-r--r--compiler/commands.nim8
-rw-r--r--lib/system.nim2
-rw-r--r--tests/newconfig/tfoo.nim2
-rw-r--r--tests/newconfig/tfoo.nims21
5 files changed, 30 insertions, 6 deletions
diff --git a/changelog.md b/changelog.md
index 32d7eba55..cdd6c031a 100644
--- a/changelog.md
+++ b/changelog.md
@@ -137,6 +137,9 @@
   nim r compiler/nim.nim --fullhelp # no recompilation
   nim r --nimcache:/tmp main # binary saved to /tmp/main
   ```
+- `--hint:processing` is now supported and means `--hint:processing:on`
+  (likewise with other hints and warnings), which is consistent with all other bool flags.
+  (since 1.3.3).
 
 ## Tool changes
 
diff --git a/compiler/commands.nim b/compiler/commands.nim
index 949d6cae1..e980d64fc 100644
--- a/compiler/commands.nim
+++ b/compiler/commands.nim
@@ -176,7 +176,7 @@ proc expectNoArg(conf: ConfigRef; switch, arg: string, pass: TCmdLinePass, info:
 
 proc processSpecificNote*(arg: string, state: TSpecialWord, pass: TCmdLinePass,
                          info: TLineInfo; orig: string; conf: ConfigRef) =
-  var id = ""  # arg = key:val or [key]:val;  with val=on|off
+  var id = ""  # arg = key or [key] or key:val or [key]:val;  with val=on|off
   var i = 0
   var n = hintMin
   var isBracket = false
@@ -190,7 +190,8 @@ proc processSpecificNote*(arg: string, state: TSpecialWord, pass: TCmdLinePass,
     if i < arg.len and arg[i] == ']': inc(i)
     else: invalidCmdLineOption(conf, pass, orig, info)
 
-  if i < arg.len and (arg[i] in {':', '='}): inc(i)
+  if i == arg.len: discard
+  elif i < arg.len and (arg[i] in {':', '='}): inc(i)
   else: invalidCmdLineOption(conf, pass, orig, info)
   if state == wHint:
     let x = findStr(lineinfos.HintsToStr, id)
@@ -201,7 +202,8 @@ proc processSpecificNote*(arg: string, state: TSpecialWord, pass: TCmdLinePass,
     if x >= 0: n = TNoteKind(x + ord(warnMin))
     else: localError(conf, info, "unknown warning: " & id)
 
-  let val = substr(arg, i).normalize
+  var val = substr(arg, i).normalize
+  if val == "": val = "on"
   if val notin ["on", "off"]:
     localError(conf, info, errOnOrOffExpectedButXFound % arg)
   elif n notin conf.cmdlineNotes or pass == passCmd1:
diff --git a/lib/system.nim b/lib/system.nim
index 3f5015542..8878277b7 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -2068,7 +2068,7 @@ const
     ## is the minor number of Nim's version.
     ## Odd for devel, even for releases.
 
-  NimPatch* {.intdefine.}: int = 1
+  NimPatch* {.intdefine.}: int = 3
     ## is the patch number of Nim's version.
 
 import system/dollars
diff --git a/tests/newconfig/tfoo.nim b/tests/newconfig/tfoo.nim
index f332cd6d4..6654202c5 100644
--- a/tests/newconfig/tfoo.nim
+++ b/tests/newconfig/tfoo.nim
@@ -1,5 +1,5 @@
 discard """
-  cmd: "nim default $file"
+  cmd: "nim default --hint:cc:off --hint:cc $file"
   output: '''hello world! 0.5'''
   nimout: '''[NimScript] exec: gcc -v'''
 """
diff --git a/tests/newconfig/tfoo.nims b/tests/newconfig/tfoo.nims
index 9e6405a27..4186ee047 100644
--- a/tests/newconfig/tfoo.nims
+++ b/tests/newconfig/tfoo.nims
@@ -7,7 +7,26 @@ exec "gcc -v"
 --path: "../friends"
 
 warning("uninit", off)
-hint("processing", off)
+
+block: # supported syntaxes for hint,warning,switch
+  --hint:processing
+  hint("processing", on)
+  hint("processing", off)
+  switch("hint", "processing")
+  switch("hint", "processing:on")
+  switch("hint", "processing:off")
+  switch("hint", "[processing]")
+  switch("hint", "[processing]:on")
+  switch("hint", "[processing]:off") # leave it off
+
+  --warning:UnusedImport
+  switch("warning", "UnusedImport:off")
+  switch("warning", "UnusedImport:on")
+  switch("warning", "[UnusedImport]:off")
+  switch("warning", "[UnusedImport]:on")
+  switch("warning", "[UnusedImport]")
+  switch("warning", "UnusedImport") # leave it on
+
 #--verbosity:2
 patchFile("stdlib", "math", "mymath")