PLC-lang / rusty

Structured Text Parser and LLVM Frontend
GNU Lesser General Public License v3.0
211 stars 52 forks source link

better error message for array of struct initialization #1123

Open rarris opened 7 months ago

rarris commented 7 months ago

if we write the wrong parentheses for the array initialization, we get only a general error message

PROGRAM mainProg
VAR
testARR : struct_io := [val1:=TRUE,val2:=1]; //not ok
testARR : struct_io := (val1:=TRUE,val2:=1); //OK
END_VAR
END_PROGRAM

TYPE struct_io :
    STRUCT
        val1 : BOOL;
        val2 : INT;  
        val3 : SINT;
    END_STRUCT
END_TYPE

error: Some initial values were not generated Error: E071: Compilation aborted due to previous errors

volsa commented 6 months ago

We should return an invalid assignment error here and also give a suggestion to replace [] with () as is the case with array initializers.