mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-18 10:37:12 +00:00
fixes #23454
This commit is contained in:
@@ -496,7 +496,10 @@ proc transformAddrDeref(c: PTransf, n: PNode, kinds: TNodeKinds): PNode =
|
||||
elif n.typ.skipTypes(abstractInst).kind in {tyVar}:
|
||||
result.typ = toVar(result.typ, n.typ.skipTypes(abstractInst).kind, c.idgen)
|
||||
else:
|
||||
if n[0].kind in kinds:
|
||||
if n[0].kind in kinds and
|
||||
not (n[0][0].kind == nkSym and n[0][0].sym.kind == skForVar and
|
||||
n[0][0].typ.skipTypes(abstractVar).kind == tyTuple
|
||||
): # elimination is harmful to `for tuple unpack` because of newTupleAccess
|
||||
# addr ( deref ( x )) --> x
|
||||
result = n[0][0]
|
||||
if n.typ.skipTypes(abstractVar).kind != tyOpenArray:
|
||||
|
||||
@@ -50,3 +50,39 @@ template get*[T: not void](self: Opt[T]): T = self.value()
|
||||
method connect*(
|
||||
self: Opt[(int, int)]) =
|
||||
discard self.get()[0]
|
||||
|
||||
block: # bug #23454
|
||||
type
|
||||
Letter = enum
|
||||
A
|
||||
|
||||
LetterPairs = object
|
||||
values: seq[(Letter, string)]
|
||||
|
||||
iterator items(list: var LetterPairs): lent (Letter, string) =
|
||||
for item in list.values:
|
||||
yield item
|
||||
|
||||
var instance = LetterPairs(values: @[(A, "foo")])
|
||||
|
||||
for (a, _) in instance:
|
||||
case a
|
||||
of A: discard
|
||||
|
||||
block: # bug #23454
|
||||
type
|
||||
Letter = enum
|
||||
A
|
||||
|
||||
LetterPairs = object
|
||||
values: seq[(Letter, string)]
|
||||
|
||||
iterator items(list: var LetterPairs): var (Letter, string) =
|
||||
for item in list.values.mItems:
|
||||
yield item
|
||||
|
||||
var instance = LetterPairs(values: @[(A, "foo")])
|
||||
|
||||
for (a, _) in instance:
|
||||
case a
|
||||
of A: discard
|
||||
|
||||
Reference in New Issue
Block a user