8000 Iterating through a list of lists seems like it loses type information · Issue #102 · fubark/cyber · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Iterating through a list of lists seems like it loses type information #102
Open
@jaredkrinke

Description

@jaredkrinke

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0