Skip to content

Commit 05683e3

Browse files
committed
fixes #9633
1 parent d0a02fe commit 05683e3

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

compiler/parser.nim

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,11 @@ proc namedParams(p: var TParser, callee: PNode,
702702
# progress guaranteed
703703
exprColonEqExprListAux(p, endTok, result)
704704

705-
proc commandParam(p: var TParser, isFirstParam: var bool): PNode =
706-
result = parseExpr(p)
705+
proc commandParam(p: var TParser, isFirstParam: var bool; mode: TPrimaryMode): PNode =
706+
if mode == pmTypeDesc:
707+
result = simpleExpr(p, mode)
708+
else:
709+
result = parseExpr(p)
707710
if p.tok.tokType == tkDo:
708711
result = postExprBlocks(p, result)
709712
elif p.tok.tokType == tkEquals and not isFirstParam:
@@ -776,7 +779,7 @@ proc primarySuffix(p: var TParser, r: PNode,
776779
when true:
777780
# progress NOT guaranteed
778781
p.hasProgress = false
779-
addSon result, commandParam(p, isFirstParam)
782+
addSon result, commandParam(p, isFirstParam, mode)
780783
if not p.hasProgress: break
781784
else:
782785
while p.tok.tokType != tkEof:
@@ -1366,12 +1369,12 @@ proc parseExprStmt(p: var TParser): PNode =
13661369
while true:
13671370
getTok(p)
13681371
optInd(p, result)
1369-
addSon(result, commandParam(p, isFirstParam))
1372+
addSon(result, commandParam(p, isFirstParam, pmNormal))
13701373
if p.tok.tokType != tkComma: break
13711374
elif p.tok.indent < 0 and isExprStart(p):
13721375
result = newNode(nkCommand, a.info, @[a])
13731376
while true:
1374-
addSon(result, commandParam(p, isFirstParam))
1377+
addSon(result, commandParam(p, isFirstParam, pmNormal))
13751378
if p.tok.tokType != tkComma: break
13761379
getTok(p)
13771380
optInd(p, result)

tests/parser/tprecedence.nim

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
discard """
22
output: '''holla
33
true
4-
defabc 4'''
4+
defabc 4
5+
0'''
56
"""
67

78
# Test top level semicolon works properly:
@@ -24,3 +25,18 @@ echo "def".foo[:string, string]("abc"), " ", 4.bar[:int]
2425
proc isFalse(a: int): bool = false
2526

2627
assert not isFalse(3)
28+
29+
# bug #9633
30+
31+
type
32+
MyField = object
33+
b: seq[string]
34+
35+
MyObject = object
36+
f: MyField
37+
38+
proc getX(x: MyObject): lent MyField {.inline.} =
39+
x.f
40+
41+
let a = MyObject()
42+
echo a.getX.b.len

0 commit comments

Comments
 (0)