Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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] Accessing aliased list of lists gives nonsense #3451

Open
helehex opened this issue Sep 5, 2024 · 2 comments
Open

[BUG] Accessing aliased list of lists gives nonsense #3451

helehex opened this issue Sep 5, 2024 · 2 comments
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@helehex
Copy link
Contributor

helehex commented Sep 5, 2024

Bug description

I also tried with VariadicList, and InlineArray. Both of those work fine.
If you use var entry = ll[1][1] instead of alias entry = ll[1][1], it works. (see example)

Steps to reproduce

fn main():
    alias ll = List(List(1, 2, 3), List(4, 5, 6), List(7, 8, 9))
    alias entry = ll[1][1]
    # var entry = ll[1][1]
    print(entry)
    # prints nonsense

System information

Host Information
  ================

  Target Triple: x86_64-unknown-linux
  CPU: skylake
  CPU Features: adx, aes, avx, avx2, bmi, bmi2, clflushopt, cmov, crc32, cx16, cx8, f16c, fma, fsgsbase, fxsr, invpcid, lzcnt, mmx, movbe, pclmul, popcnt, prfchw, rdrnd, rdseed, sahf, sgx, sse, sse2, sse3, sse4.1, sse4.2, ssse3, x87, xsave, xsavec, xsaveopt, xsaves

mojo 2024.9.315 (62cda08f)

modular 0.9.2 (b3079bd5)
@helehex helehex added bug Something isn't working mojo-repo Tag all issues with this label labels Sep 5, 2024
@helehex
Copy link
Contributor Author

helehex commented Sep 5, 2024

More of an issue with UnsafePointer[UnsafePointer[...]] in general though:

fn init() -> UnsafePointer[UnsafePointer[Int]]:
    var ptr = UnsafePointer[Int].alloc(1)
    ptr[] = 5
    var ptrptr = UnsafePointer[UnsafePointer[Int]].alloc(1)
    ptrptr[] = ptr
    return ptrptr

fn main():
    alias p = init()
    alias entry = p[][] # prints nonsense
    # var entry = p[][] # prints 5
    print(entry)

@thatstoasty
Copy link
Contributor

Seems like the same root cause of an issue I raised as well #3285

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

2 participants