PLC-lang / rusty

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

Allow bit-access to bit-access assignment in arguments #1212

Open volsa opened 3 weeks ago

volsa commented 3 weeks ago

Describe the bug Should we support the following example, where the assignments are semantically similar but one will generate an error and one will not. I guess this is more of a discussion than an issue, and a good example for why AST lowering would be nice to have.

FUNCTION_BLOCK FOO
    VAR_OUTPUT
        Q : BYTE;
    END_VAR
END_FUNCTION_BLOCK

FUNCTION main : DINT
    VAR
        error_bits : BYTE;
        f : FOO;
    END_VAR

    f(Q.3 => error_bits.4); // This will yield errors ("Invalid call parameters", "Expression is not assignable")

    // This will not yield any errors, but it is semantically similar to the above function call
    error_bits.3 := error_bits.4;

END_FUNCTION