rusty icon indicating copy to clipboard operation
rusty copied to clipboard

Add validation for initializers

Open mhasel opened this issue 2 years ago • 0 comments

Currently there is no validation in place for variables being initialized in variable blocks. Trying to initialize a variable with an invalid type will fail during codegen, but not be reported beforehand. e.g.:

VAR_GLOBAL
      a : (red, yellow, green) := (1, 2, 3);
      b : INT := 'wrong type';
      c : STRING := 10(1000);
      d : ARRAY[0..1] OF WSTRING := 1000;
END_VAR

FUNCTION main : DINT
    VAR
        a : (red, yellow, green) := (1, 2, 3);
        b : INT := 'wrong type';
        c : STRING := 10(1000);
        d : ARRAY[0..1] OF WSTRING := 1000;
    END_VAR
END_FUNCTION

mhasel avatar Jun 05 '23 06:06 mhasel