PLC-lang / rusty

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

feat: Validate types in math operations #1300

Closed volsa closed 2 months ago

volsa commented 2 months ago

Adds a validation to check if a math operation has incompatible types. For example the following code previously had no validation and as a consequence would panic during codegen.

FUNCTION main : DINT
    VAR
        x1 : ARRAY[0..2] OF TOD;
        x2 : STRING;
    END_VAR

    x1 + x2;
    ADD(x1, x1);
    DIV(x1, x2);
    SUB(x2, x2);
END_FUNCTION

Resolves https://github.com/PLC-lang/rusty/issues/1038