diff options
-rw-r--r-- | compiler/semstmts.nim | 3 | ||||
-rw-r--r-- | tests/tuples/t9177.nim | 1 | ||||
-rw-r--r-- | tests/tuples/ttuples_various.nim | 21 |
3 files changed, 23 insertions, 2 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 1cf8e7ab2..6a92e9221 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -641,7 +641,8 @@ proc semConst(c: PContext, n: PNode): PNode = addSon(b, copyTree(def)) else: setVarType(c, v, typ.sons[j]) - v.ast = def[j] + v.ast = if def[j].kind != nkExprColonExpr: def[j] + else: def[j].sons[1] b.sons[j] = newSymNode(v) addSon(result,b) dec c.inStaticContext diff --git a/tests/tuples/t9177.nim b/tests/tuples/t9177.nim index d5768b703..e6dd0cb1d 100644 --- a/tests/tuples/t9177.nim +++ b/tests/tuples/t9177.nim @@ -1,6 +1,5 @@ discard """ action: run - disabled: true """ block: diff --git a/tests/tuples/ttuples_various.nim b/tests/tuples/ttuples_various.nim index 94a2f3ff0..dc060da1e 100644 --- a/tests/tuples/ttuples_various.nim +++ b/tests/tuples/ttuples_various.nim @@ -81,6 +81,27 @@ block unpack_const: doAssert z == 6 +# bug #10724 +block unpack_const_named: + const (a, ) = (x: 1, ) + doAssert a == 1 + + const (b, c) = (x: 2, y: 3) + doAssert b == 2 + doAssert c == 3 + + const (d, e, f) = (x: 4, y: 5, z: 6) + doAssert d == 4 + doAssert e == 5 + doAssert f == 6 + +block const_named: + const x = block: + (a: 1, b: 2, c: 3) + doAssert x.a == 1 + doAssert x.b == 2 + doAssert x.c == 3 + block tuple_subscript: proc`[]` (t: tuple, key: string): string = |