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
commit a65189a739
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 17 additions and 15 deletions

View file

@ -125,9 +125,11 @@ proc styleCheckUse*(conf: ConfigRef; info: TLineInfo; s: PSym) =
return return
let newName = s.name.s let newName = s.name.s
let oldName = differs(conf, info, newName) let badName = differs(conf, info, newName)
if oldName.len > 0: if badName.len > 0:
lintReport(conf, info, newName, oldName) # 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) = proc checkPragmaUse*(conf: ConfigRef; info: TLineInfo; w: TSpecialWord; pragmaName: string) =
let wanted = $w let wanted = $w

View file

@ -612,9 +612,9 @@ template internalAssert*(conf: ConfigRef, e: bool) =
let arg = info2.toFileLineCol let arg = info2.toFileLineCol
internalErrorImpl(conf, unknownLineInfo, arg, info2) internalErrorImpl(conf, unknownLineInfo, arg, info2)
template lintReport*(conf: ConfigRef; info: TLineInfo, beau, got: string) = template lintReport*(conf: ConfigRef; info: TLineInfo, beau, got: string, forceHint = false) =
let m = "'$2' should be: '$1'" % [beau, got] let m = "'$1' should be: '$2'" % [got, beau]
let msg = if optStyleError in conf.globalOptions: errGenerated else: hintName let msg = if optStyleError in conf.globalOptions and not forceHint: errGenerated else: hintName
liMessage(conf, info, msg, m, doNothing, instLoc()) liMessage(conf, info, msg, m, doNothing, instLoc())
proc quotedFilename*(conf: ConfigRef; i: TLineInfo): Rope = proc quotedFilename*(conf: ConfigRef; i: TLineInfo): Rope =

View file

@ -1135,7 +1135,7 @@ AST:
.. code-block:: nim .. code-block:: nim
# ... # ...
nnkTypeClassTy( # note this isn't nnkConceptTy! nnkTypeClassTy( # note this isn't nnkConceptTy!
nnkArglist( nnkArgList(
# ... idents for x, y, z # ... 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 echo x + y * z - x
This passes the expression `x + y * z - x` to the `optM` macro as This passes the expression `x + y * z - x` to the `optM` macro as
an `nnkArglist` node containing:: an `nnkArgList` node containing::
Arglist Arglist
Sym "x" Sym "x"

View file

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

View file

@ -322,7 +322,7 @@ macro html*(e: varargs[untyped]): untyped =
macro hr*(): untyped = macro hr*(): untyped =
## Generates the HTML `hr` element. ## 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 = macro i*(e: varargs[untyped]): untyped =
## Generates the HTML `i` element. ## Generates the HTML `i` element.

View file

@ -39,7 +39,7 @@ proc underscoredCall(n, arg0: NimNode): NimNode =
result.add arg0 result.add arg0
proc underscoredCalls*(result, calls, arg0: NimNode) = proc underscoredCalls*(result, calls, arg0: NimNode) =
expectKind calls, {nnkArglist, nnkStmtList, nnkStmtListExpr} expectKind calls, {nnkArgList, nnkStmtList, nnkStmtListExpr}
for call in calls: for call in calls:
if call.kind in {nnkStmtList, nnkStmtListExpr}: if call.kind in {nnkStmtList, nnkStmtListExpr}:

View file

@ -929,7 +929,7 @@ static:
(x & y & z) is string (x & y & z) is string
ast.peelOff({nnkStmtList, nnkTypeSection}).matchAst: ast.peelOff({nnkStmtList, nnkTypeSection}).matchAst:
of nnkTypeDef(_, _, nnkTypeClassTy(nnkArglist, _, _, nnkStmtList)): of nnkTypeDef(_, _, nnkTypeClassTy(nnkArgList, _, _, nnkStmtList)):
# note this isn't nnkConceptTy! # note this isn't nnkConceptTy!
echo "ok" echo "ok"

View file

@ -1,6 +1,6 @@
discard """ discard """
errormsg: ''' 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' nnkSharedTy, # 'shared T'
nnkEnumTy, nnkEnumTy,
nnkEnumFieldDef, nnkEnumFieldDef,
nnkArglist, nnkPattern nnkArgList, nnkPattern
nnkReturnToken, nnkReturnToken,
nnkClosure, nnkClosure,
nnkGotoState, nnkGotoState,

View file

@ -64,7 +64,7 @@ block t7723:
block t8706: block t8706:
macro varargsLen(args:varargs[untyped]): untyped = macro varargsLen(args:varargs[untyped]): untyped =
doAssert args.kind == nnkArglist doAssert args.kind == nnkArgList
doAssert args.len == 0 doAssert args.len == 0
result = newLit(args.len) result = newLit(args.len)