rusty icon indicating copy to clipboard operation
rusty copied to clipboard

initialization of references support

Open rarris opened this issue 1 year ago • 2 comments

Example:

PROGRAM mainProg
VAR
	myInt: INT;
	myRefInt: REF_TO INT := REF(myInt);
	myF1: F1;
	myRefF1: REF_TO F1 := REF(myF1);
END_VAR
END_PROGRAM

FUNCTION_BLOCK F1
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
END_VAR
;
END_FUNCTION_BLOCK

after compilation, the following error outputs:

error: Unresolved constant `myRefInt` variable: Cannot resolve constant: CallStatement {
    operator: ReferenceExpr {
        kind: Member(
            Identifier {
                name: "REF",
            },
        ),
        base: None,
    },
    parameters: Some(
        ReferenceExpr {
            kind: Member(
                Identifier {
                    name: "myInt",
                },
            ),
            base: None,
        },
    ),
}
error: Unresolved constant `myRefF1` variable: Cannot resolve constant: CallStatement {
    operator: ReferenceExpr {
        kind: Member(
            Identifier {
                name: "REF",
            },
        ),
        base: None,
    },
    parameters: Some(
        ReferenceExpr {
            kind: Member(
                Identifier {
                    name: "myF1",
                },
            ),
            base: None,
        },
    ),
}
Error: E001: Compilation aborted due to critical errors

rarris avatar Feb 13 '24 05:02 rarris

error update:

: error[E071]: Could not resolve reference to myInt Compilation aborted due to previous errors

rarris avatar Oct 10 '24 08:10 rarris

This is also tracked in #1286 and happens because referencing local, unqualified members in REF/ADR is not yet supported. I'll close the other issue in favor of this one.

mhasel avatar Oct 14 '24 12:10 mhasel