nnkArglist => nnkArgList + special case stylecheck:error (#17529)

* nnkArglist => nnkArgList

* special case stylecheck:error
This commit is contained in:
Timothee Cour
2021-03-27 02:28:11 -07:00
committed by GitHub
parent 8ed6de4fe6
commit a65189a739
10 changed files with 17 additions and 15 deletions

View File

@@ -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

View File

@@ -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 =

View File

@@ -1135,7 +1135,7 @@ AST:
.. code-block:: nim
# ...
nnkTypeClassTy( # note this isn't nnkConceptTy!
nnkArglist(
nnkArgList(
# ... idents for x, y, z
)
# ...

View File

@@ -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"

View File

@@ -78,7 +78,7 @@ type
nnkSharedTy, # 'shared T'
nnkEnumTy,
nnkEnumFieldDef,
nnkArglist, nnkPattern
nnkArgList, nnkPattern
nnkHiddenTryStmt,
nnkClosure,
nnkGotoState,

View File

@@ -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.

View File

@@ -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}:

View File

@@ -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"

View File

@@ -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,

View File

@@ -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)