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

Iterating through a list of lists seems like it loses type information #102

Open
jaredkrinke opened this issue Jan 7, 2025 · 0 comments

Comments

@jaredkrinke
Copy link

Disclaimer: I don't know if this is supported or expected to work.

Using v0.4-DEV on x86-64 Linux, if I try to access an array using an index from a list of list of indices (List[List[int]]) while iterating, Cyber panics (third print in the code). It seems like maybe the type information is wrong because if I wrap the value in int(...), then everything works fine (second print in the code). Accessing outside of a "for each" loop seems to work fine as well (first print in the code).

Minimal code sample:

var nestedIndices = List[List[int]]{ List[int]{1} }
var values = List[int]{3, 4, 5}

-- Works
print values[nestedIndices[0][0]]

for nestedIndices -> indices:
  -- Works
  print values[int(indices[0])]
  -- panic: Out of bounds
  print values[indices[0]]

I'm expecting the program to print the number 4 three times. Instead, I see:

4
4
panic: Out of bounds.
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

No branches or pull requests

1 participant