diff options
author | Juan Carlos <juancarlospaco@gmail.com> | 2023-05-11 05:10:51 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-11 10:10:51 +0200 |
commit | 3a08e2e6ace20f086ba24360c7139852a75b93b2 (patch) | |
tree | ca858bb347eeb1f153521a9b34c02d44b53d04e1 | |
parent | 055a00a6eff6fabd0f5fdf061d0eb28d07aa41a9 (diff) | |
download | Nim-3a08e2e6ace20f086ba24360c7139852a75b93b2.tar.gz |
Remove LineTooLong (#21819)
* LineTooLong refactor to make it actually useful * Improve error message * changelog wording * Fix typo
-rw-r--r-- | changelogs/changelog_2_0_0.md | 2 | ||||
-rw-r--r-- | compiler/lexer.nim | 5 | ||||
-rw-r--r-- | compiler/lineinfos.nim | 2 | ||||
-rw-r--r-- | compiler/options.nim | 1 | ||||
-rw-r--r-- | config/nim.cfg | 1 | ||||
-rw-r--r-- | doc/manual.md | 20 | ||||
-rw-r--r-- | doc/nimc.md | 1 |
7 files changed, 13 insertions, 19 deletions
diff --git a/changelogs/changelog_2_0_0.md b/changelogs/changelog_2_0_0.md index 17e3d32e5..e89cb6b62 100644 --- a/changelogs/changelog_2_0_0.md +++ b/changelogs/changelog_2_0_0.md @@ -455,6 +455,8 @@ - When compiling for Release the flag `-fno-math-errno` is used for GCC. - When compiling for Release the flag `--build-id=none` is used for GCC Linker. +- Removed deprecated `LineTooLong` hint. + ## Docgen diff --git a/compiler/lexer.nim b/compiler/lexer.nim index 67dafc59f..5962c8b9b 100644 --- a/compiler/lexer.nim +++ b/compiler/lexer.nim @@ -23,7 +23,6 @@ when defined(nimPreviewSlimSystem): import std/[assertions, formatfloat] const - MaxLineLength* = 80 # lines longer than this lead to a warning numChars*: set[char] = {'0'..'9', 'a'..'z', 'A'..'Z'} SymChars*: set[char] = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF'} SymStartChars*: set[char] = {'a'..'z', 'A'..'Z', '\x80'..'\xFF'} @@ -736,10 +735,6 @@ proc handleCRLF(L: var Lexer, pos: int): int = template registerLine = let col = L.getColNumber(pos) - when not defined(nimpretty): - if col > MaxLineLength: - lexMessagePos(L, hintLineTooLong, pos) - case L.buf[pos] of CR: registerLine() diff --git a/compiler/lineinfos.nim b/compiler/lineinfos.nim index 7a51a4db7..f6d0d6264 100644 --- a/compiler/lineinfos.nim +++ b/compiler/lineinfos.nim @@ -94,7 +94,6 @@ type # hints hintSuccess = "Success", hintSuccessX = "SuccessX", hintCC = "CC", - hintLineTooLong = "LineTooLong", hintXDeclaredButNotUsed = "XDeclaredButNotUsed", hintDuplicateModuleImport = "DuplicateModuleImport", hintXCannotRaiseY = "XCannotRaiseY", hintConvToBaseNotNeeded = "ConvToBaseNotNeeded", hintConvFromXtoItselfNotNeeded = "ConvFromXtoItselfNotNeeded", hintExprAlwaysX = "ExprAlwaysX", @@ -198,7 +197,6 @@ const # keep in sync with `testament.isSuccess` hintSuccessX: "$build\n$loc lines; ${sec}s; $mem; proj: $project; out: $output", hintCC: "CC: $1", - hintLineTooLong: "line too long", hintXDeclaredButNotUsed: "'$1' is declared but not used", hintDuplicateModuleImport: "$1", hintXCannotRaiseY: "$1", diff --git a/compiler/options.nim b/compiler/options.nim index a9f1e7542..c0b99744c 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -416,6 +416,7 @@ type expandNodeResult*: string expandPosition*: TLineInfo + proc parseNimVersion*(a: string): NimVer = # could be moved somewhere reusable if a.len > 0: diff --git a/config/nim.cfg b/config/nim.cfg index cc27d5a3d..656885e0c 100644 --- a/config/nim.cfg +++ b/config/nim.cfg @@ -14,7 +14,6 @@ cc = gcc # additional options always passed to the compiler: --parallel_build: "0" # 0 to auto-detect number of processors -hint[LineTooLong]=off @if nimHasAmbiguousEnumHint: # not needed if hint is a style check hint[AmbiguousEnum]=off diff --git a/doc/manual.md b/doc/manual.md index ed225e51b..7fe9923f4 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -6889,7 +6889,7 @@ iterator in which case the overloading resolution takes place: var x = 4 write(stdout, x) # not ambiguous: uses the module C's x ``` -Modules can share their name, however, when trying to qualify a identifier with the module name the compiler will fail with ambiguous identifier error. One can qualify the identifier by aliasing the module. +Modules can share their name, however, when trying to qualify a identifier with the module name the compiler will fail with ambiguous identifier error. One can qualify the identifier by aliasing the module. ```nim @@ -6914,7 +6914,7 @@ C.fb() # Error: ambiguous identifier: 'fb' ```nim import A/C as fizz -import B/C +import B/C fizz.fb() # Works ``` @@ -7253,7 +7253,7 @@ echo foo() # 2 template foo: int = 3 ``` -This is mostly intended for macro generated code. +This is mostly intended for macro generated code. compilation option pragmas -------------------------- @@ -7323,7 +7323,7 @@ but are used to override the settings temporarily. Example: template example(): string = "https://nim-lang.org" {.pop.} - {.push deprecated, hint[LineTooLong]: off, used, stackTrace: off.} + {.push deprecated, used, stackTrace: off.} proc sample(): bool = true {.pop.} ``` @@ -7362,14 +7362,14 @@ and before any variable in a module that imports it. Disabling certain messages -------------------------- -Nim generates some warnings and hints ("line too long") that may annoy the +Nim generates some warnings and hints that may annoy the user. A mechanism for disabling certain messages is provided: Each hint and warning message is associated with a symbol. This is the message's identifier, which can be used to enable or disable the message by putting it in brackets following the pragma: ```Nim - {.hint[LineTooLong]: off.} # turn off the hint about too long lines + {.hint[XDeclaredButNotUsed]: off.} # Turn off the hint about declared but not used symbols. ``` This is often better than disabling all warnings at once. @@ -8072,7 +8072,7 @@ CodegenDecl pragma ------------------ The `codegenDecl` pragma can be used to directly influence Nim's code -generator. It receives a format string that determines how the variable, +generator. It receives a format string that determines how the variable, proc or object type is declared in the generated code. For variables, $1 in the format string represents the type of the variable, @@ -8108,7 +8108,7 @@ will generate this code: ```c __interrupt void myinterrupt() ``` - + For object types, the $1 represents the name of the object type, $2 is the list of fields and $3 is the base type. @@ -8117,7 +8117,7 @@ fields and $3 is the base type. const strTemplate = """ struct $1 { $2 - }; + }; """ type Foo {.codegenDecl:strTemplate.} = object a, b: int @@ -8130,7 +8130,7 @@ will generate this code: struct Foo { NI a; NI b; -}; +}; ``` `cppNonPod` pragma diff --git a/doc/nimc.md b/doc/nimc.md index 3abc340c6..7c42c7c1b 100644 --- a/doc/nimc.md +++ b/doc/nimc.md @@ -115,7 +115,6 @@ ExprAlwaysX ExtendedContext GCStats Dumps statistics about the Garbage Collector. GlobalVar Shows global variables declarations. -LineTooLong Line exceeds the maximum length. Link Linking phase. Name Path Search paths modifications. |