odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.23k stars 555 forks source link

Cannot assign to variable with 2 levels of `using` through a pointer. #2538

Open jakubtomsu opened 1 year ago

jakubtomsu commented 1 year ago

Context

        Odin: dev-2023-05-nightly:0c352213
        OS:   Windows 10 Professional (version: 22H2), build 19045.2965
        CPU:  Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
        RAM:  32681 MiB

Expected Behavior

I should be able to assign variables with multiple levels of using.

Steps to Reproduce

Bar :: struct {
    a: f32,
}

Foo :: struct {
    using bar: ^Bar,
    b: i32,
}

do_foo :: proc(using foo: Foo) {
    foo.a = 123 // Works
    a = 123 // Doesn't work (Error: Cannot assign to 'a')
}

This shows:

D:/projects/odin-metroidvania/build.odin(86:5) Error: Cannot assign to 'a'
        a = 123
        ^
gingerBill commented 1 year ago

Tangent: I know this is a bug but I do kind of regret allowing using in this way 😜

jakubtomsu commented 1 year ago

Lol, yeah I could see using begin used to make the code more convoluted / difficult to understand...