mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-22 07:15:22 +00:00
fixes #1791
This commit is contained in:
@@ -1907,12 +1907,11 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
var ids = initIntSet()
|
||||
for i in 1.. <n.len:
|
||||
let it = n.sons[i]
|
||||
if it.kind != nkExprColonExpr or it.sons[0].kind notin {nkSym, nkIdent}:
|
||||
if it.kind != nkExprColonExpr:
|
||||
localError(n.info, errNamedExprExpected)
|
||||
break
|
||||
var id: PIdent
|
||||
if it.sons[0].kind == nkIdent: id = it.sons[0].ident
|
||||
else: id = it.sons[0].sym.name
|
||||
let id = considerQuotedIdent(it.sons[0])
|
||||
|
||||
if containsOrIncl(ids, id.id):
|
||||
localError(it.info, errFieldInitTwice, id.s)
|
||||
var e = semExprWithType(c, it.sons[1], flags*{efAllowDestructor})
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
discard """
|
||||
output: '''(k: kindA, a: (x: abc, z: [1, 1, 3]), empty: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 2, 3]), empty: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 3, 3]), empty: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 4, 3]), empty: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 5, 3]), empty: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 6, 3]), empty: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 7, 3]), empty: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 8, 3]), empty: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 9, 3]), empty: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 10, 3]), empty: ())'''
|
||||
output: '''(k: kindA, a: (x: abc, z: [1, 1, 3]), method: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 2, 3]), method: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 3, 3]), method: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 4, 3]), method: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 5, 3]), method: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 6, 3]), method: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 7, 3]), method: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 8, 3]), method: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 9, 3]), method: ())
|
||||
(k: kindA, a: (x: abc, z: [1, 10, 3]), method: ())'''
|
||||
"""
|
||||
|
||||
type
|
||||
@@ -20,9 +20,9 @@ type
|
||||
TDummy = ref object
|
||||
case k: TKind
|
||||
of kindXY: x, y: int
|
||||
of kindA:
|
||||
of kindA:
|
||||
a: TArg
|
||||
empty: TEmpty
|
||||
`method`: TEmpty # bug #1791
|
||||
|
||||
proc `$`[T](s: seq[T]): string =
|
||||
# XXX why is that not in the stdlib?
|
||||
@@ -34,7 +34,7 @@ proc `$`[T](s: seq[T]): string =
|
||||
|
||||
proc main() =
|
||||
for i in 1..10:
|
||||
let d = TDummy(k: kindA, a: TArg(x: "abc", z: @[1,i,3]), empty: TEmpty())
|
||||
let d = TDummy(k: kindA, a: TArg(x: "abc", z: @[1,i,3]), `method`: TEmpty())
|
||||
echo d[]
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user