rusty
rusty copied to clipboard
Refactor: error message for initializing multiple variables
Is your refactor request related to a problem? Please describe.
VAR
a, b, c : INT := (0, 1, 2);
END_VAR
This code is wrong and won't compile because IEC61131-3 doesn't support initializing multiple variables with a parenthesized list.
The error the compiler returns is:
Expected Struct-literal, got ExpressionList {
expressions: [
LiteralInteger {
value: 0,
},
LiteralInteger {
value: 1,
},
LiteralInteger {
value: 2,
},
],
} at: myfile.st
Describe the solution you'd like IMO this is not very helpful for the user. We should give the user more information on the problem. Maybe something like this would be more helpful:
Error: Multiple variable declarations require individual initializers
Found: a, b, c : INT := (0, 1, 2)
Expected format: a : INT := 0;
b : INT := 1;
c : INT := 2;