improve error message for twrongcolon
This commit is contained in:
parent
fa0f5d0238
commit
2199f83280
3 changed files with 15 additions and 4 deletions
|
|
@ -914,7 +914,7 @@ proc parseIdentColonEquals(p: var TParser, flags: TDeclaredIdentFlags): PNode =
|
||||||
optInd(p, result)
|
optInd(p, result)
|
||||||
addSon(result, parseTypeDesc(p))
|
addSon(result, parseTypeDesc(p))
|
||||||
else:
|
else:
|
||||||
addSon(result, ast.emptyNode)
|
addSon(result, newNodeP(nkEmpty, p))
|
||||||
if p.tok.tokType != tkEquals and withBothOptional notin flags:
|
if p.tok.tokType != tkEquals and withBothOptional notin flags:
|
||||||
parMessage(p, errColonOrEqualsExpected, p.tok)
|
parMessage(p, errColonOrEqualsExpected, p.tok)
|
||||||
if p.tok.tokType == tkEquals:
|
if p.tok.tokType == tkEquals:
|
||||||
|
|
@ -922,7 +922,7 @@ proc parseIdentColonEquals(p: var TParser, flags: TDeclaredIdentFlags): PNode =
|
||||||
optInd(p, result)
|
optInd(p, result)
|
||||||
addSon(result, parseExpr(p))
|
addSon(result, parseExpr(p))
|
||||||
else:
|
else:
|
||||||
addSon(result, ast.emptyNode)
|
addSon(result, newNodeP(nkEmpty, p))
|
||||||
|
|
||||||
proc parseTuple(p: var TParser, indentAllowed = false): PNode =
|
proc parseTuple(p: var TParser, indentAllowed = false): PNode =
|
||||||
#| inlTupleDecl = 'tuple'
|
#| inlTupleDecl = 'tuple'
|
||||||
|
|
|
||||||
|
|
@ -277,9 +277,9 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
|
||||||
|
|
||||||
if overloadsState == csEmpty and result.state == csEmpty:
|
if overloadsState == csEmpty and result.state == csEmpty:
|
||||||
if nfDotField in n.flags and nfExplicitCall notin n.flags:
|
if nfDotField in n.flags and nfExplicitCall notin n.flags:
|
||||||
localError(n.info, errUndeclaredField, considerQuotedIdent(f).s)
|
localError(n.info, errUndeclaredField, considerQuotedIdent(f, n).s)
|
||||||
else:
|
else:
|
||||||
localError(n.info, errUndeclaredRoutine, considerQuotedIdent(f).s)
|
localError(n.info, errUndeclaredRoutine, considerQuotedIdent(f, n).s)
|
||||||
return
|
return
|
||||||
elif result.state != csMatch:
|
elif result.state != csMatch:
|
||||||
if nfExprCall in n.flags:
|
if nfExprCall in n.flags:
|
||||||
|
|
|
||||||
11
tests/errmsgs/twrongcolon.nim
Normal file
11
tests/errmsgs/twrongcolon.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "in expression '("
|
||||||
|
nimout: '''
|
||||||
|
Error: in expression '(
|
||||||
|
890)': identifier expected, but found ''
|
||||||
|
'''
|
||||||
|
|
||||||
|
line: 11
|
||||||
|
"""
|
||||||
|
|
||||||
|
var n: int : 890
|
||||||
Loading…
Add table
Add a link
Reference in a new issue