You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Operating System & Odin Version:
Odin: dev-2024-04:9bbe26f80
OS: Windows 11 Professional (version: 22H2), build 22621.3447
CPU: Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
RAM: 16227 MiB
Backend: LLVM 17.0.1
Expected Behavior
The compiler should either accept this and produce valid code, actually modifying the field with the second initialization, or produce a compile error if it's undesirable behavior.
Current Behavior
Inside the default_struct i initialize inner by calling default_inner_struct and then attempt to overwrite one of the imported fields, inner_number_a, with the value 222. However, printing the field, we can see the output is 69, the value returned from deafult_inner_proc, and not 222, the expected value.
Steps to Reproduce
package main
import"core:fmt"
InnerStruct :: struct {
inner_number_a: int,
inner_number_b: int,
}
default_inner_struct :: proc() -> InnerStruct {
return {
inner_number_a = 69,
inner_number_b = 420,
}
}
Struct :: struct {
using inner: InnerStruct,
}
default_struct :: proc() -> Struct {
s := Struct {
inner = default_inner_struct(),
inner_number_a = 222,
}
return s
}
main :: proc() {
s := default_struct()
// Prints 69, ignoring the second initialization at L:23 to 222.
fmt.printfln("%v", s.inner_number_a)
}
The text was updated successfully, but these errors were encountered:
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Expected Behavior
The compiler should either accept this and produce valid code, actually modifying the field with the second initialization, or produce a compile error if it's undesirable behavior.
Current Behavior
Inside the
default_struct
i initializeinner
by callingdefault_inner_struct
and then attempt to overwrite one of the imported fields,inner_number_a
, with the value 222. However, printing the field, we can see the output is 69, the value returned fromdeafult_inner_proc
, and not 222, the expected value.Steps to Reproduce
The text was updated successfully, but these errors were encountered: