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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] cannot access the index of non-array type #559

Closed
0rphon opened this issue Jan 21, 2021 · 4 comments
Closed

[Bug] cannot access the index of non-array type #559

0rphon opened this issue Jan 21, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@0rphon
Copy link
Contributor

0rphon commented Jan 21, 2021

馃悰 Bug Report

Code snippet to reproduce

function main () {
    let x = [false; (2, 2)];
    let y: bool = x[0][0];
}

Error

 Compiling     --> "d:\\Work\\leo_playground\\src/main.leo": 3:23
     |
   3 |      let y: bool = x[0][0];
     |                        ^^^
     |
     = Cannot access the index of non-array type `bool`.

Expected Behavior

[[false, false], [false, false]] indexed by [0][0] should return a bool

Your Environment

  • leo's latest github commit 39d0222
  • rustc 1.49.0 (e1884a8e3 2020-12-29)
  • windows 10 build 10.0.19042.746
@0rphon 0rphon added the bug Something isn't working label Jan 21, 2021
@0rphon
Copy link
Contributor Author

0rphon commented Jan 21, 2021

another example that seems to be the same error with a different message

function main () {
    //[[[0], [0], [0], [0]], [[0], [0], [0], [0]], [[0], [0], [0], [0]], [[0], [0], [0], [0]]]
    let x: [[u8; (4, 1)]; 4] = [[0u8; (4, 4, 1)], [0u8; (4, 1)], [0u8; (4, 1)], [0u8; (4, 1)]];
    let y: [u8; 1] = x[3][1u32];
}
 Compiling     --> "d:\\Work\\leo_playground\\src/main.leo": 4:5
     |
   4 |      let y: [u8; 1] = x[3][1u32];
     |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = Mismatched types. Expected type `[u8]`, found type `u8`.

@damons
Copy link

damons commented Jan 22, 2021

Will this be fixed in the ASG patch?

@Protryon
Copy link
Contributor

Fixed by ASG.

@0rphon
Copy link
Contributor Author

0rphon commented Feb 3, 2021

fixed by asg (2657c44)

@0rphon 0rphon 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

3 participants