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

[Bug] multidimensional array indexing failing #591

Closed
bendyarm opened this issue Feb 1, 2021 · 1 comment
Closed

[Bug] multidimensional array indexing failing #591

bendyarm opened this issue Feb 1, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@bendyarm
Copy link
Collaborator

bendyarm commented Feb 1, 2021

🐛 Bug Report

Build error for arr[i][j]

Steps to Reproduce

This happens if I do leo build on howardwu/silly-sudoku:

Compiling     --> "/home/batman/silly-sudoku/src/lib.leo": 38:53
     |
  38 |                  let grid_value = self.puzzle_grid[i][j];
     |                                                      ^^^
     |
     = Cannot access the index of non-array type `u8`.

I also tried this simpler version, which got the same error:

function main(puzzle: [u8; (3, 3)]) -> bool {
    console.log("{}", puzzle);
    let c: u8 = puzzle[1][0];
    return (c == 3)
}

with the array2d.in file:

[main]
puzzle: [u8; (3, 3)] = [[0, 4, 6],
                        [3, 0, 9],
                        [7, 5, 0]];

[registers]
r0: bool = false;

But when I didn't pass the 2d array through the parameter, this worked:

function main() -> bool {
    let puzzle: [u8; (3, 3)] = [[0, 4, 6],
                                [3, 0, 9],
                                [7, 5, 0]];

    let c: u8 = puzzle[1][0];
    return (c == 3)
}

Your Environment

  • Leo v1.0.8
  • rustc 1.48.0
  • linux mint 19.3
@bendyarm bendyarm added the bug Something isn't working label Feb 1, 2021
@Protryon
Copy link
Contributor

Protryon commented Feb 3, 2021

fixed by asg

@Protryon Protryon closed this as completed Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants