diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-11-08 08:15:10 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-11-08 09:15:15 +0100 |
commit | 05683e3aab430abdaeefba144a07f468d33aa8ee (patch) | |
tree | 6b86062ec6ddea7a96ca39d5fe94be6475f85376 | |
parent | d0a02fe66bb01ef49645a11562c72fa585170b8e (diff) | |
download | Nim-05683e3aab430abdaeefba144a07f468d33aa8ee.tar.gz |
fixes #9633
-rw-r--r-- | compiler/parser.nim | 13 | ||||
-rw-r--r-- | tests/parser/tprecedence.nim | 18 |
2 files changed, 25 insertions, 6 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index fd2a52e78..a48b2d41e 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -702,8 +702,11 @@ proc namedParams(p: var TParser, callee: PNode, # progress guaranteed exprColonEqExprListAux(p, endTok, result) -proc commandParam(p: var TParser, isFirstParam: var bool): PNode = - result = parseExpr(p) +proc commandParam(p: var TParser, isFirstParam: var bool; mode: TPrimaryMode): PNode = + if mode == pmTypeDesc: + result = simpleExpr(p, mode) + else: + result = parseExpr(p) if p.tok.tokType == tkDo: result = postExprBlocks(p, result) elif p.tok.tokType == tkEquals and not isFirstParam: @@ -776,7 +779,7 @@ proc primarySuffix(p: var TParser, r: PNode, when true: # progress NOT guaranteed p.hasProgress = false - addSon result, commandParam(p, isFirstParam) + addSon result, commandParam(p, isFirstParam, mode) if not p.hasProgress: break else: while p.tok.tokType != tkEof: @@ -1366,12 +1369,12 @@ proc parseExprStmt(p: var TParser): PNode = while true: getTok(p) optInd(p, result) - addSon(result, commandParam(p, isFirstParam)) + addSon(result, commandParam(p, isFirstParam, pmNormal)) if p.tok.tokType != tkComma: break elif p.tok.indent < 0 and isExprStart(p): result = newNode(nkCommand, a.info, @[a]) while true: - addSon(result, commandParam(p, isFirstParam)) + addSon(result, commandParam(p, isFirstParam, pmNormal)) if p.tok.tokType != tkComma: break getTok(p) optInd(p, result) diff --git a/tests/parser/tprecedence.nim b/tests/parser/tprecedence.nim index cdf4ad3ee..aff7c6aca 100644 --- a/tests/parser/tprecedence.nim +++ b/tests/parser/tprecedence.nim @@ -1,7 +1,8 @@ discard """ output: '''holla true -defabc 4''' +defabc 4 +0''' """ # Test top level semicolon works properly: @@ -24,3 +25,18 @@ echo "def".foo[:string, string]("abc"), " ", 4.bar[:int] proc isFalse(a: int): bool = false assert not isFalse(3) + +# bug #9633 + +type + MyField = object + b: seq[string] + + MyObject = object + f: MyField + +proc getX(x: MyObject): lent MyField {.inline.} = + x.f + +let a = MyObject() +echo a.getX.b.len |