-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
The compiler currently fails to detect when type names are used as values in expressions during the validation phase. This results in a late-stage codegen error that is cryptic and unhelpful to users. Current Behavior When a type name is used as a value in an assignment or expression, the compiler fails during codegen with:
Could not resolve reference to <TYPE> at: <location>
Hint: You can use plc explain <ErrorCode> for more information
To Reproduce
Steps to reproduce the behavior:
Compile this code example:
PROGRAM main
VAR
a : INT;
b : MyInt;
c : Color;
d : MyStruct;
END_VAR
a := INT; // Type name as value
b := MyInt; // Type name as value - alias type
c := Color; // Type name as value - enum type
d := MyStruct; // Type name as value - struct type
END_PROGRAM
Here's another example:
TYPE Color : INT (red := 1, green := 2, blue := 3); END_TYPE
VAR_GLOBAL
myColor : Color;
END_VAR
PROGRAM main
myColor := red; // Unqualified variant - ok
myColor := Color; // Type itself - should be unresolvable
END_PROGRAM
Expected behavior
The compiler should detect this during the validation phase (before codegen) and emit a clear diagnostic message
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working