PLC-lang / rusty

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

Validation for shadowed variables #1179

Open volsa opened 1 month ago

volsa commented 1 month ago

Is your feature request related to a problem? Please describe. Currently the the following code compiles without any info / warning messages but it isn't clear which x value is meant in the assignment y := x.

VAR_GLOBAL CONSTANT
    x : DINT := 0;
END_VAR

PROGRAM main
    VAR
        x : DINT := 10;
        y : DINT;
    END_VAR
    y := x;
END_PROGRAM

Describe the solution you'd like Give a warning that the global x variable is shadowed by the local one (or vice-versa, depending on how we define the behavior of such cases).