From 75f427a57b765d2c0d359da39722efbe1dabf2e0 Mon Sep 17 00:00:00 2001 From: Clyybber Date: Tue, 7 Jul 2020 10:21:18 +0200 Subject: [PATCH] Fix #14911 (#14922) [backport] * Fix #14911 * Add testcase * Fix test (cherry picked from commit 5bd2da3f6461ef4dbcfd1f0c35178fa8fa9b5368) --- compiler/semexprs.nim | 2 +- tests/tuples/ttuples_issues.nim | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 36decffba4..d3324399b4 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -2401,7 +2401,7 @@ proc checkPar(c: PContext; n: PNode): TParKind = for i in 0 ..< length: if result == paTupleFields: if (n.sons[i].kind != nkExprColonExpr) or - n.sons[i].sons[0].kind notin {nkSym, nkIdent}: + n.sons[i].sons[0].kind notin {nkSym, nkIdent, nkAccQuoted}: localError(c.config, n.sons[i].info, errNamedExprExpected) return paNone else: diff --git a/tests/tuples/ttuples_issues.nim b/tests/tuples/ttuples_issues.nim index 9380bd027d..f294f2f1ce 100644 --- a/tests/tuples/ttuples_issues.nim +++ b/tests/tuples/ttuples_issues.nim @@ -1,5 +1,7 @@ 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: 192'u32) ] + +# bug #14911 +echo (a: 1) # works +echo (`a`: 1) # works +echo (`a`: 1, `b`: 2) # Error: named expression expected