rusty icon indicating copy to clipboard operation
rusty copied to clipboard

Shadowing parent variables in `VAR_TEMP` blocks

Open mhasel opened this issue 8 months ago • 1 comments

should we allow shadowing parent variables with temp vars ?

FUNCTION_BLOCK fb
VAR
    x: INT := 10;
END_VAR
END_FUNCTION_BLOCK

FUNCTION_BLOCK fb2 EXTENDS fb
// the following var-block will currently cause a compile error
VAR_TEMP 
     x: INT := 20;
END_VAR
END_FUNCTION_BLOCK
         I would lean towards yes, but maybe track this in a separate issue to discuss there?

Originally posted by @volsa in https://github.com/PLC-lang/rusty/pull/1445#discussion_r2035192899

mhasel avatar Apr 11 '25 08:04 mhasel

I say yes with a warning

ghaith avatar Apr 11 '25 08:04 ghaith