rusty icon indicating copy to clipboard operation
rusty copied to clipboard

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

Open mhasel opened this issue 1 year ago • 0 comments

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.

mhasel avatar Mar 26 '24 15:03 mhasel