fixes #1791
This commit is contained in:
parent
dfc48e76f7
commit
4077f7d49c
2 changed files with 16 additions and 17 deletions
|
|
@ -1907,12 +1907,11 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
var ids = initIntSet()
|
var ids = initIntSet()
|
||||||
for i in 1.. <n.len:
|
for i in 1.. <n.len:
|
||||||
let it = n.sons[i]
|
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)
|
localError(n.info, errNamedExprExpected)
|
||||||
break
|
break
|
||||||
var id: PIdent
|
let id = considerQuotedIdent(it.sons[0])
|
||||||
if it.sons[0].kind == nkIdent: id = it.sons[0].ident
|
|
||||||
else: id = it.sons[0].sym.name
|
|
||||||
if containsOrIncl(ids, id.id):
|
if containsOrIncl(ids, id.id):
|
||||||
localError(it.info, errFieldInitTwice, id.s)
|
localError(it.info, errFieldInitTwice, id.s)
|
||||||
var e = semExprWithType(c, it.sons[1], flags*{efAllowDestructor})
|
var e = semExprWithType(c, it.sons[1], flags*{efAllowDestructor})
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''(k: kindA, a: (x: abc, z: [1, 1, 3]), empty: ())
|
output: '''(k: kindA, a: (x: abc, z: [1, 1, 3]), method: ())
|
||||||
(k: kindA, a: (x: abc, z: [1, 2, 3]), empty: ())
|
(k: kindA, a: (x: abc, z: [1, 2, 3]), method: ())
|
||||||
(k: kindA, a: (x: abc, z: [1, 3, 3]), empty: ())
|
(k: kindA, a: (x: abc, z: [1, 3, 3]), method: ())
|
||||||
(k: kindA, a: (x: abc, z: [1, 4, 3]), empty: ())
|
(k: kindA, a: (x: abc, z: [1, 4, 3]), method: ())
|
||||||
(k: kindA, a: (x: abc, z: [1, 5, 3]), empty: ())
|
(k: kindA, a: (x: abc, z: [1, 5, 3]), method: ())
|
||||||
(k: kindA, a: (x: abc, z: [1, 6, 3]), empty: ())
|
(k: kindA, a: (x: abc, z: [1, 6, 3]), method: ())
|
||||||
(k: kindA, a: (x: abc, z: [1, 7, 3]), empty: ())
|
(k: kindA, a: (x: abc, z: [1, 7, 3]), method: ())
|
||||||
(k: kindA, a: (x: abc, z: [1, 8, 3]), empty: ())
|
(k: kindA, a: (x: abc, z: [1, 8, 3]), method: ())
|
||||||
(k: kindA, a: (x: abc, z: [1, 9, 3]), empty: ())
|
(k: kindA, a: (x: abc, z: [1, 9, 3]), method: ())
|
||||||
(k: kindA, a: (x: abc, z: [1, 10, 3]), empty: ())'''
|
(k: kindA, a: (x: abc, z: [1, 10, 3]), method: ())'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -20,9 +20,9 @@ type
|
||||||
TDummy = ref object
|
TDummy = ref object
|
||||||
case k: TKind
|
case k: TKind
|
||||||
of kindXY: x, y: int
|
of kindXY: x, y: int
|
||||||
of kindA:
|
of kindA:
|
||||||
a: TArg
|
a: TArg
|
||||||
empty: TEmpty
|
`method`: TEmpty # bug #1791
|
||||||
|
|
||||||
proc `$`[T](s: seq[T]): string =
|
proc `$`[T](s: seq[T]): string =
|
||||||
# XXX why is that not in the stdlib?
|
# XXX why is that not in the stdlib?
|
||||||
|
|
@ -34,7 +34,7 @@ proc `$`[T](s: seq[T]): string =
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
for i in 1..10:
|
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[]
|
echo d[]
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue