-
-
Notifications
You must be signed in to change notification settings - Fork 570
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
"Maybe" assignment failing on struct initilization #3956
Comments
Can you give us some code that triggers the assert in your linked repo, like a main proc that calls the procedure that asserts in it? |
You will find it in regui/GUI.odin and then in the init function. |
Yes but just putting a main proc that imports and calls that doesn't work and fails with errors about a missing package ex_defs |
Ok got it down to this repro: package bug
Bar :: union {
int,
}
Foo :: union {
Bar,
}
FooBar :: struct {
foo: Foo,
}
main :: proc() {
foo := FooBar {
foo = 69, // Make this `Bar(69)` and it fixes it.
}
assert(foo.foo != nil)
} It has to do with this hack: Odin/src/llvm_backend_expr.cpp Line 4738 in 68550cf
Adding a panic at This hack evidently does not work with nested unions. I ran out of time to think of a fix (would probably be some kind of recursive/looping solution to account for multiple levels) so I am leaving this info here. |
Hmm, I don't experience this, as you can see in my project it seems to work fine for the double union (the "default" struct member), but it does not work for the Maybe and then double union (The "hover" and "active" struct memebers.) Here is the struct for clarification:
|
Don't experience what? Remember a Maybe is just a union under the hood. And this also only happens with compound literals with inferred types. I am 99% sure this is your bug. |
Context
This was talked about at: https://discord.com/channels/568138951836172421/568871298428698645/1264674940611858482
Observe the following code:
The assertion failes.
Now observe the following code:
The assertion no longer failes.
Odin version:
Odin: dev-2024-07-nightly:b4ca044
OS: Windows 11 Home Basic (version: 23H2), build 22631.3880
CPU: 13th Gen Intel(R) Core(TM) i9-13900HX
RAM: 32507 MiB
Backend: LLVM 17.0.1
Expected Behavior
I would expect that the first assertion did not fail.
Current Behavior
The first assertions fails.
Failure Information (for bugs)
I think this is a bug with "Maybe", it seems to not get assigned.
Steps to Reproduce
I have not been able to reproduce this is a simple setup. See "things tested" for more info.
To find a example which failes go to: https://github.com/xzores/furbs/tree/Bug_found
Download and Run the project, it should fail.
things tested
I have tested the following which DID work as expected:
I have also tried:
I have also tried:
ALL OF THIS PASSED, so I have been unable to replicate the bug in a simpler setup.
The text was updated successfully, but these errors were encountered: