Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Mar 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions compiler/linter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions compiler/msgs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion doc/astspec.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ AST:
.. code-block:: nim
# ...
nnkTypeClassTy( # note this isn't nnkConceptTy!
nnkArglist(
nnkArgList(
# ... idents for x, y, z
)
# ...
Expand Down
2 changes: 1 addition & 1 deletion doc/manual_experimental.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion lib/core/macros.nim
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type
nnkSharedTy, # 'shared T'
nnkEnumTy,
nnkEnumFieldDef,
nnkArglist, nnkPattern
nnkArgList, nnkPattern
nnkHiddenTryStmt,
nnkClosure,
nnkGotoState,
Expand Down
2 changes: 1 addition & 1 deletion lib/pure/htmlgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/std/private/underscored_calls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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}:
Expand Down
2 changes: 1 addition & 1 deletion tests/astspec/tastspec.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions tests/casestmt/tincompletecaseobject.nim
Original file line number Diff line number Diff line change
@@ -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}
'''
"""

Expand Down Expand Up @@ -62,7 +62,7 @@ type
nnkSharedTy, # 'shared T'
nnkEnumTy,
nnkEnumFieldDef,
nnkArglist, nnkPattern
nnkArgList, nnkPattern
nnkReturnToken,
nnkClosure,
nnkGotoState,
Expand Down
2 changes: 1 addition & 1 deletion tests/macros/tmacros_issues.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down