mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
Remove LineTooLong (#21819)
* LineTooLong refactor to make it actually useful * Improve error message * changelog wording * Fix typo
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -416,6 +416,7 @@ type
|
||||
expandNodeResult*: string
|
||||
expandPosition*: TLineInfo
|
||||
|
||||
|
||||
proc parseNimVersion*(a: string): NimVer =
|
||||
# could be moved somewhere reusable
|
||||
if a.len > 0:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user