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

Unable to iterate on SoA's that are in a map #4671

Open
ottah opened this issue Jan 9, 2025 · 0 comments
Open

Unable to iterate on SoA's that are in a map #4671

ottah opened this issue Jan 9, 2025 · 0 comments

Comments

@ottah
Copy link

ottah commented Jan 9, 2025

Context

I am unable to loop through SoA's that are part of a map as the compiler will not build the project.
For example this will not work

Foo :: struct {
   bar: int,
   baz: int,
}
map[int]#soa[dynamic]Foo

Odin: dev-2024-11-nightly:e6475fe
OS: Windows 10 Professional (version: 22H2), build 19045.5247
CPU: AMD Ryzen 9 5950X 16-Core Processor
RAM: 65460 MiB
Backend: LLVM 18.1.8

Expected Behavior

Normal behavior for an #soa. Looping through each field of the struct or each struct.

Failure Information (for bugs)

D:\a\Odin\Odin\src\llvm_backend_general.cpp(1338): Assertion Failure: `t->kind == Type_Struct && t->Struct.soa_kind != StructSoa_None` 

Steps to Reproduce

If you run the following code you will see the build error

main :: proc () {
    Foo :: struct {
        id: uint,
        item: uint
    }
    table : map[string] (#soa[dynamic]Foo)
    table["key"] = make_soa_dynamic_array(#soa[dynamic]Foo)
    append_soa(&table["key"], Foo{
        id = 0,
        item = uint(4)
    })
    fmt.println("This works", table["key"].item[0]) // this works

    // This will fail to build
    for &el in table["key"] {
        fmt.println(el)
    }
}
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