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

Compiler error when 'using' is applied to a #soa pointer #2041

Open
jakubtomsu opened this issue Sep 10, 2022 · 0 comments
Open

Compiler error when 'using' is applied to a #soa pointer #2041

jakubtomsu opened this issue Sep 10, 2022 · 0 comments
Labels

Comments

@jakubtomsu
Copy link
Contributor

Context

Operating System & Odin Version:

        Odin: dev-2022-09-nightly:74458ab0
        OS:   Windows 10 Professional (version: 21H1), build 19043.1889
        CPU:  Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
        RAM:  32681 MiB

Expected Behavior

using statement would work fine on #soa pointers, just like on normal pointers and structs.

Current Behavior

When I try to use using on a #soa pointer, compiler shows an error. It seems like the compiler thinks the value is an immutable procedure parameter. Note that assigning a value directly without the using statement works fine.

Failure Information (for bugs)

In the example below, the compiler shows this error:
Cannot assign to 'b' which is from a 'using' procedure parameter

Steps to Reproduce

Here is a short example code which triggers the error:

Foo :: struct {
    a, b, c: f32,
}

main :: proc() {
    foos: #soa[32]Foo
    for i in 0..<len(foos) {
        updateFoo(&foos[i])
    }
}

updateFoo :: proc(foo: #soa^#soa[32]Foo) {
    // Working with foo directly is without any issues:
    foo.a = 123
    foo.b = 456
    using foo
    b = 1234 // Error: Cannot assign to 'b' which is from a 'using' procedure parameter
}

Also when using is applied directly to the procedure parameter, the compiler shows a different error - Cannot assign to 'b':

updateFoo :: proc(using foo: #soa^#soa[32]Foo) {
    foo.a = 123
    foo.b = 456
    b = 1234 // Error: Cannot assign to 'b'
}

I'm using just odin run to run this example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant