Odin
Odin copied to clipboard
Compiler error when 'using' is applied to a #soa pointer
trafficstars
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.