Fix #14911 (#14922) [backport]

* Fix #14911

* Add testcase

* Fix test
This commit is contained in:
Clyybber 2020-07-07 10:21:18 +02:00 • committed by GitHub
commit 5bd2da3f64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -2432,7 +2432,7 @@ proc checkPar(c: PContext; n: PNode): TParKind =
for i in 0..<n.len: for i in 0..<n.len:
if result == paTupleFields: if result == paTupleFields:
if (n[i].kind != nkExprColonExpr) or if (n[i].kind != nkExprColonExpr) or
n[i][0].kind notin {nkSym, nkIdent}: n[i][0].kind notin {nkSym, nkIdent, nkAccQuoted}:
localError(c.config, n[i].info, errNamedExprExpected) localError(c.config, n[i].info, errNamedExprExpected)
return paNone return paNone
else: else:

View file

@ -1,5 +1,7 @@
discard """ discard """
output: ''' output: '''(a: 1)
(a: 1)
(a: 1, b: 2)
''' '''
""" """
@ -75,3 +77,8 @@ block t1986:
(var1: test(), var2: 100'u32), (var1: test(), var2: 100'u32),
(var1: test(), var2: 192'u32) (var1: test(), var2: 192'u32)
] ]
# bug #14911
echo (a: 1) # works
echo (`a`: 1) # works
echo (`a`: 1, `b`: 2) # Error: named expression expected