summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2021-03-27 02:28:11 -0700
committerGitHub <noreply@github.com>2021-03-27 10:28:11 +0100
commita65189a739c59fcc0d7b3f8fdcb2cf8bed432f68 (patch)
tree079934acdaad7f51edd35b54e2390c3c2f08daed
parent8ed6de4fe6517dc4db38ab5dea898c0016d1c08a (diff)
downloadNim-a65189a739c59fcc0d7b3f8fdcb2cf8bed432f68.tar.gz
nnkArglist => nnkArgList + special case stylecheck:error (#17529)
* nnkArglist => nnkArgList

* special case stylecheck:error
-rw-r--r--compiler/linter.nim8
-rw-r--r--compiler/msgs.nim6
-rw-r--r--doc/astspec.txt2
-rw-r--r--doc/manual_experimental.rst2
-rw-r--r--lib/core/macros.nim2
-rw-r--r--lib/pure/htmlgen.nim2
-rw-r--r--lib/std/private/underscored_calls.nim2
-rw-r--r--tests/astspec/tastspec.nim2
-rw-r--r--tests/casestmt/tincompletecaseobject.nim4
-rw-r--r--tests/macros/tmacros_issues.nim2
10 files changed, 17 insertions, 15 deletions
diff --git a/compiler/linter.nim b/compiler/linter.nim
index 1ae1fb097..9af4f468e 100644
--- a/compiler/linter.nim
+++ b/compiler/linter.nim
@@ -125,9 +125,11 @@ proc styleCheckUse*(conf: ConfigRef; info: TLineInfo; s: PSym) =
     return
 
   let newName = s.name.s
-  let oldName = differs(conf, info, newName)
-  if oldName.len > 0:
-    lintReport(conf, info, newName, oldName)
+  let badName = differs(conf, info, newName)
+  if badName.len > 0:
+    # special rules for historical reasons
+    let forceHint = badName == "nnkArgList" and newName == "nnkArglist" or badName == "nnkArglist" and newName == "nnkArgList"
+    lintReport(conf, info, newName, badName, forceHint = forceHint)
 
 proc checkPragmaUse*(conf: ConfigRef; info: TLineInfo; w: TSpecialWord; pragmaName: string) =
   let wanted = $w
diff --git a/compiler/msgs.nim b/compiler/msgs.nim
index bbe40507f..24855ae18 100644
--- a/compiler/msgs.nim
+++ b/compiler/msgs.nim
@@ -612,9 +612,9 @@ template internalAssert*(conf: ConfigRef, e: bool) =
     let arg = info2.toFileLineCol
     internalErrorImpl(conf, unknownLineInfo, arg, info2)
 
-template lintReport*(conf: ConfigRef; info: TLineInfo, beau, got: string) =
-  let m = "'$2' should be: '$1'" % [beau, got]
-  let msg = if optStyleError in conf.globalOptions: errGenerated else: hintName
+template lintReport*(conf: ConfigRef; info: TLineInfo, beau, got: string, forceHint = false) =
+  let m = "'$1' should be: '$2'" % [got, beau]
+  let msg = if optStyleError in conf.globalOptions and not forceHint: errGenerated else: hintName
   liMessage(conf, info, msg, m, doNothing, instLoc())
 
 proc quotedFilename*(conf: ConfigRef; i: TLineInfo): Rope =
diff --git a/doc/astspec.txt b/doc/astspec.txt
index c49f7bcc2..b4b8b34b5 100644
--- a/doc/astspec.txt
+++ b/doc/astspec.txt
@@ -1135,7 +1135,7 @@ AST:
 .. code-block:: nim
   # ...
   nnkTypeClassTy( # note this isn't nnkConceptTy!
-    nnkArglist(
+    nnkArgList(
       # ... idents for x, y, z
     )
     # ...
diff --git a/doc/manual_experimental.rst b/doc/manual_experimental.rst
index cf2e0c247..fc46a2a14 100644
--- a/doc/manual_experimental.rst
+++ b/doc/manual_experimental.rst
@@ -1283,7 +1283,7 @@ all the arguments, but also the matched operators in reverse polish notation:
   echo x + y * z - x
 
 This passes the expression `x + y * z - x` to the `optM` macro as
-an `nnkArglist` node containing::
+an `nnkArgList` node containing::
 
   Arglist
     Sym "x"
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index 5a556fc8d..8d6258e80 100644
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -78,7 +78,7 @@ type
     nnkSharedTy,           # 'shared T'
     nnkEnumTy,
     nnkEnumFieldDef,
-    nnkArglist, nnkPattern
+    nnkArgList, nnkPattern
     nnkHiddenTryStmt,
     nnkClosure,
     nnkGotoState,
diff --git a/lib/pure/htmlgen.nim b/lib/pure/htmlgen.nim
index 163f9303b..89eb24bb9 100644
--- a/lib/pure/htmlgen.nim
+++ b/lib/pure/htmlgen.nim
@@ -322,7 +322,7 @@ macro html*(e: varargs[untyped]): untyped =
 
 macro hr*(): untyped =
   ## Generates the HTML `hr` element.
-  result = xmlCheckedTag(newNimNode(nnkArglist), "hr", commonAttr, "", true)
+  result = xmlCheckedTag(newNimNode(nnkArgList), "hr", commonAttr, "", true)
 
 macro i*(e: varargs[untyped]): untyped =
   ## Generates the HTML `i` element.
diff --git a/lib/std/private/underscored_calls.nim b/lib/std/private/underscored_calls.nim
index 6d0a99ab5..f0bcbcc74 100644
--- a/lib/std/private/underscored_calls.nim
+++ b/lib/std/private/underscored_calls.nim
@@ -39,7 +39,7 @@ proc underscoredCall(n, arg0: NimNode): NimNode =
     result.add arg0
 
 proc underscoredCalls*(result, calls, arg0: NimNode) =
-  expectKind calls, {nnkArglist, nnkStmtList, nnkStmtListExpr}
+  expectKind calls, {nnkArgList, nnkStmtList, nnkStmtListExpr}
 
   for call in calls:
     if call.kind in {nnkStmtList, nnkStmtListExpr}:
diff --git a/tests/astspec/tastspec.nim b/tests/astspec/tastspec.nim
index 3413d32f3..e2cfed277 100644
--- a/tests/astspec/tastspec.nim
+++ b/tests/astspec/tastspec.nim
@@ -929,7 +929,7 @@ static:
         (x & y & z) is string
 
     ast.peelOff({nnkStmtList, nnkTypeSection}).matchAst:
-    of nnkTypeDef(_, _, nnkTypeClassTy(nnkArglist, _, _, nnkStmtList)):
+    of nnkTypeDef(_, _, nnkTypeClassTy(nnkArgList, _, _, nnkStmtList)):
       # note this isn't nnkConceptTy!
       echo "ok"
 
diff --git a/tests/casestmt/tincompletecaseobject.nim b/tests/casestmt/tincompletecaseobject.nim
index 909ee4e1c..aa5deda7a 100644
--- a/tests/casestmt/tincompletecaseobject.nim
+++ b/tests/casestmt/tincompletecaseobject.nim
@@ -1,6 +1,6 @@
 discard """
 errormsg: '''
-not all cases are covered; missing: {nnkComesFrom, nnkDotCall, nnkHiddenCallConv, nnkVarTuple, nnkCurlyExpr, nnkRange, nnkCheckedFieldExpr, nnkDerefExpr, nnkElifExpr, nnkElseExpr, nnkLambda, nnkDo, nnkBind, nnkClosedSymChoice, nnkHiddenSubConv, nnkConv, nnkStaticExpr, nnkAddr, nnkHiddenAddr, nnkHiddenDeref, nnkObjDownConv, nnkObjUpConv, nnkChckRangeF, nnkChckRange64, nnkChckRange, nnkStringToCString, nnkCStringToString, nnkFastAsgn, nnkGenericParams, nnkFormalParams, nnkOfInherit, nnkImportAs, nnkConverterDef, nnkMacroDef, nnkTemplateDef, nnkIteratorDef, nnkOfBranch, nnkElifBranch, nnkExceptBranch, nnkElse, nnkAsmStmt, nnkTypeDef, nnkFinally, nnkContinueStmt, nnkImportStmt, nnkImportExceptStmt, nnkExportStmt, nnkExportExceptStmt, nnkFromStmt, nnkIncludeStmt, nnkUsingStmt, nnkBlockExpr, nnkStmtListType, nnkBlockType, nnkWith, nnkWithout, nnkTypeOfExpr, nnkObjectTy, nnkTupleTy, nnkTupleClassTy, nnkTypeClassTy, nnkStaticTy, nnkRecList, nnkRecCase, nnkRecWhen, nnkVarTy, nnkConstTy, nnkMutableTy, nnkDistinctTy, nnkProcTy, nnkIteratorTy, nnkSharedTy, nnkEnumTy, nnkEnumFieldDef, nnkArglist, nnkPattern, nnkReturnToken, nnkClosure, nnkGotoState, nnkState, nnkBreakState, nnkFuncDef, nnkTupleConstr}
+not all cases are covered; missing: {nnkComesFrom, nnkDotCall, nnkHiddenCallConv, nnkVarTuple, nnkCurlyExpr, nnkRange, nnkCheckedFieldExpr, nnkDerefExpr, nnkElifExpr, nnkElseExpr, nnkLambda, nnkDo, nnkBind, nnkClosedSymChoice, nnkHiddenSubConv, nnkConv, nnkStaticExpr, nnkAddr, nnkHiddenAddr, nnkHiddenDeref, nnkObjDownConv, nnkObjUpConv, nnkChckRangeF, nnkChckRange64, nnkChckRange, nnkStringToCString, nnkCStringToString, nnkFastAsgn, nnkGenericParams, nnkFormalParams, nnkOfInherit, nnkImportAs, nnkConverterDef, nnkMacroDef, nnkTemplateDef, nnkIteratorDef, nnkOfBranch, nnkElifBranch, nnkExceptBranch, nnkElse, nnkAsmStmt, nnkTypeDef, nnkFinally, nnkContinueStmt, nnkImportStmt, nnkImportExceptStmt, nnkExportStmt, nnkExportExceptStmt, nnkFromStmt, nnkIncludeStmt, nnkUsingStmt, nnkBlockExpr, nnkStmtListType, nnkBlockType, nnkWith, nnkWithout, nnkTypeOfExpr, nnkObjectTy, nnkTupleTy, nnkTupleClassTy, nnkTypeClassTy, nnkStaticTy, nnkRecList, nnkRecCase, nnkRecWhen, nnkVarTy, nnkConstTy, nnkMutableTy, nnkDistinctTy, nnkProcTy, nnkIteratorTy, nnkSharedTy, nnkEnumTy, nnkEnumFieldDef, nnkArgList, nnkPattern, nnkReturnToken, nnkClosure, nnkGotoState, nnkState, nnkBreakState, nnkFuncDef, nnkTupleConstr}
 '''
 """
 
@@ -62,7 +62,7 @@ type
     nnkSharedTy,           # 'shared T'
     nnkEnumTy,
     nnkEnumFieldDef,
-    nnkArglist, nnkPattern
+    nnkArgList, nnkPattern
     nnkReturnToken,
     nnkClosure,
     nnkGotoState,
diff --git a/tests/macros/tmacros_issues.nim b/tests/macros/tmacros_issues.nim
index 19c706a82..a964f46ba 100644
--- a/tests/macros/tmacros_issues.nim
+++ b/tests/macros/tmacros_issues.nim
@@ -64,7 +64,7 @@ block t7723:
 
 block t8706:
   macro varargsLen(args:varargs[untyped]): untyped =
-    doAssert args.kind == nnkArglist
+    doAssert args.kind == nnkArgList
     doAssert args.len == 0
     result = newLit(args.len)