PLC-lang / rusty

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

Cryptic codegen error when trying to assign boolean `VAR_OUTPUT` to specific bit of `BYTE` variable #1176

Open mhasel opened 1 month ago

mhasel commented 1 month ago

Describe the bug Writing a boolean value returned from a VAR_OUTPUT block into a bit-accessed bit will result in an error during codegen:

error[E071]: ()
   ┌─ target/demo.st:55:12
   │
55 │     f(Q => error_bits.0);
   │            ^^^^^^^^^^^^ ()

Error: Compilation aborted due to previous errors.

To Reproduce

FUNCTION_BLOCK FOO
VAR_OUTPUT 
    Q : BOOL;
END_VAR
END_FUNCTION_BLOCK

FUNCTION main : DINT 
VAR
    error_bits : BYTE;
    f : FOO;
END_VAR
    f(Q => error_bits.0);
END_FUNCTION

Expected behavior The access bit of error_bits should have the value of f.Q after the call.

Additional context A similar example with TON was found in a test project.