summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2019-07-14 16:08:52 +0200
committerAraq <rumpf_a@web.de>2019-07-14 16:08:52 +0200
commite06046ab51660f2f227618ad263b64911c4d8a63 (patch)
treee3925680e81bd6488d15aabc9859e5d3ba4dc57b /compiler
parentfab70e4fe3b9e1fd20a333f17b667c7a85a835fb (diff)
downloadNim-e06046ab51660f2f227618ad263b64911c4d8a63.tar.gz
makes --styleCheck:error the default for the Nim compiler itself
Diffstat (limited to 'compiler')
-rw-r--r--compiler/linter.nim19
-rw-r--r--compiler/nim.cfg2
2 files changed, 16 insertions, 5 deletions
diff --git a/compiler/linter.nim b/compiler/linter.nim
index 9aa2272f2..abefe9bec 100644
--- a/compiler/linter.nim
+++ b/compiler/linter.nim
@@ -72,11 +72,20 @@ proc beautifyName(s: string, k: TSymKind): string =
     inc i
 
 proc differ*(line: string, a, b: int, x: string): string =
-  let y = line[a..b]
-  if y != x and cmpIgnoreStyle(y, x) == 0:
-    result = y
-  else:
-    result = ""
+  proc substrEq(s: string, pos, last: int, substr: string): bool =
+    var i = 0
+    var length = substr.len
+    while i < length and pos+i <= last and s[pos+i] == substr[i]:
+      inc i
+    return i == length
+
+  let last = min(b, line.len)
+
+  result = ""
+  if not substrEq(line, a, b, x):
+    let y = line[a..b]
+    if cmpIgnoreStyle(y, x) == 0:
+      result = y
 
 proc checkStyle(conf: ConfigRef; cache: IdentCache; info: TLineInfo, s: string, k: TSymKind; sym: PSym) =
   let beau = beautifyName(s, k)
diff --git a/compiler/nim.cfg b/compiler/nim.cfg
index 841b72a94..6f266317f 100644
--- a/compiler/nim.cfg
+++ b/compiler/nim.cfg
@@ -14,6 +14,8 @@ define:nimcore
 define:useStdoutAsStdmsg
 define:nimOldCaseObjects
 
+styleCheck:error
+
 #define:useNodeIds
 #gc:markAndSweep