-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
Weird compile output when using Maybe
type in union definition
#3503
Comments
You say you can't have type aliases with generics. Does the following program not do what you want? package main
Type :: struct($T: typeid) {
var: T,
}
Type_Int :: Type(int)
main :: proc () {
a: Type_Int
a.var = 42
} Or did you mean something like
|
Yes, this would work really well.
In your example you still have to access the field
It's a really small thing tho and your example is probably the best way to it. |
If you want to preserve the I'm not sure what else you might want to accomplish beyond those two though. I would need to know more about the end goal. |
The issue isn't really about having aliases tho, I did use what you are commenting and it did work. |
Context
I was writing an union to be a wrapper for a single type, because you can't have type aliases with generics, at least I think you can't (if someone knows how to, please tell me)
The code is:
Which is really simple, there's literally nothing else to the code
for some reason the compiler gives me this error:
I have no idea why it would give me an error on the core library of odin, is this normal and I'm doing something i'm not supposed to with types/unions? If I remove Maybe from the type it doesn't show nay errors.
Even if this is normal behavior it really doesn't clarify what is the issue very well.
note: I have noticed after some time that I don't actually need the
Maybe
because since it is an union it can already be of valuenil
anyway, but I'm opening this issue anyway because I feel that the error message is at least strange.Expected Behavior
Given how simple the types are, I would expect it to compile without any error messages, or at least give a better error message.
Current Behavior
Already explained in
Context
section.The text was updated successfully, but these errors were encountered: