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
Describe the bug
When skipping initialization for some struct fields, a codegen error pops up due to said skipped value not being generated. For example
TYPE STRUCT1 : STRUCT
node : DINT;
myArr : ARRAY[0..1] OF STRUCT2;
END_STRUCT END_TYPE
TYPE STRUCT2 : STRUCT
x1 : INT;
x2 : INT;
END_STRUCT END_TYPE
PROGRAM main
VAR
var_init1 : ARRAY[0..1] OF STRUCT1 := [
(node := 0, myArr := [(x1 := 0)])
];
END_VAR
END_PROGRAM
will yield the following error
error: Some initial values were not generated
Codegen Error: Compilation aborted due to previous errors
Similarly this will not work (myArr := [(x1 := 0, x2 := 1), (x1 := 2, x2 := 3)]).
When initializing x2 / node however, it seem to work i.e. (node := 0, myArr := [(x1 := 0, x2 := 0)]).
Additional context
This seems like a regression due to 5dac39d
The text was updated successfully, but these errors were encountered:
…ucts (#1020)
Fixes#1019
This commit adds a type-hint on struct field assignments when dealing with array of structs. For example given structs
- `STRUCT1 { idx: DINT, arr: ARRAY[...] OF STRUCT2 }` and
- `STRUCT2 { x: DINT, y: DINT }`
The following snippet `ARRAY[1..3] OF STRUCT1 := [(idx := 0, arr := [(x := 1)])];` will result in `idx := 0` having a type-hint on `STRUCT1` and `x := 1` on `STRUCT2`
Describe the bug
When skipping initialization for some struct fields, a codegen error pops up due to said skipped value not being generated. For example
will yield the following error
Similarly this will not work
(myArr := [(x1 := 0, x2 := 1), (x1 := 2, x2 := 3)])
.When initializing
x2
/node
however, it seem to work i.e.(node := 0, myArr := [(x1 := 0, x2 := 0)])
.Additional context
This seems like a regression due to 5dac39d
The text was updated successfully, but these errors were encountered: