Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #23454; IndexDefect thrown when destructuring a lent tuple #23458

Closed
wants to merge 2 commits into from

Conversation

ringabout
Copy link
Member

fixes #23454

@Araq
Copy link
Member

Araq commented Apr 2, 2024

Adhoc solution plus it's unclear to me why var T would not have the same problem.

@ringabout
Copy link
Member Author

Well, var T does have the similar problems

without mitems

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:
      yield item

  var instance = LetterPairs(values: @[(A, "foo")])

  for (a, _) in instance:
    case a
    of A: discard

gives expression has no address, I suppose there is a hidden address for var/lent

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
Error: unhandled exception: index 1 not in 0 .. 0 [IndexDefect]

compiler/transf.nim Outdated Show resolved Hide resolved
compiler/transf.nim Outdated Show resolved Hide resolved
@ringabout
Copy link
Member Author

Succeeded by #23963

@ringabout ringabout closed this Aug 15, 2024
@ringabout ringabout deleted the pr_lent_yield branch August 15, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IndexDefect thrown when destructuring a lent value
2 participants