Skip to content

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

Closed
@mhasel

Description

@mhasel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions