Skip to content

Missing validation for unresolved references in conditionals #1559

@mhasel

Description

@mhasel

Describe the bug
When a reference in an IF-statement condition is not resolvable, we do not currently catch that during validation. Instead, the user receives a rather cryptic cannot generate call statement for ReferenceExpr { kind: Member(Identifier { name: "UINT_EQUAL" }), base: None } at: ....

To Reproduce
Steps to reproduce the behavior:
compile the following:

TYPE ErrorCode :
STRUCT
    Lib     : UINT;     (**< Error library code *)
    Reason  : UINT;     (**< Error reason code *)
    Func    : UDINT;    (**< Error function code *)
END_STRUCT
END_TYPE

PROGRAM mainProg
VAR
    Error: ErrorCode;
END_VAR

IF Error.Reason <> ERROR_OK THEN // unresolved reference in conditional

END_IF
END_PROGRAM

Expected behavior
A clear, concise and helpful error message about the unresolved reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    validationcandidate for syntactic or semantic validation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions