PLC-lang / rusty

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

Unary expression `+ <REAL>` panics on `unimplemented!()` #1171

Open mhasel opened 1 month ago

mhasel commented 1 month ago

Describe the bug Unary expressions with an explicit + operator on REALs will panic in https://github.com/PLC-lang/rusty/blob/b357a05cb064eb21fed110b6d7c5f543f72c18e8/src/codegen/generators/expression_generator.rs#L400 The same expression with INTs is fine.

To Reproduce This came up while porting a project and the MRE boils down to this:

FUNCTION main: DINT
VAR
    r: REAL;
    i: INT;
END_VAR
    i := + 6; // this is fine
    r := + r; // hits `unimplemented!()` in `expression_generator.rs:400`
    r := + 6.0; // same as above
END_FUNCTION

Expected behavior the expression + 6.0 behaving just like 6.0

volsa commented 1 month ago

Related PR https://github.com/PLC-lang/rusty/pull/640