Passing a VLA to a function from within another function using `VAR_IN_OUT`
Describe the bug
Passing a VLA to a function from within another function using VAR_IN_OUT results in a compilation error. Not sure if this is intended behavior, but the example apparently compiles in at least one other IEC 61131-compliant environment.
To Reproduce
FUNCTION bar
VAR_IN_OUT
val : ARRAY[*] OF LREAL;
END_VAR
END_FUNCTION
FUNCTION foo
VAR_IN_OUT
val : ARRAY[*] OF LREAL;
END_VAR
bar(val);
END_FUNCTION
Compiling yields error[E037]: Invalid assignment: cannot assign 'ARRAY[*] OF LREAL' to 'ARRAY[*] OF LREAL'.
Expected behavior Both functions should reference the same array.
I'm assuming we should not do any check here, if we're going from 1 compatible vla to the other, we can just copy the fat pointer to the next function. The underlying array pointer would remain the same.
This doesn't seem to be limited to VLAs. I can reproduce this with ARRAY[...] OF ARRAY[...] in a VAR_IN_OUT block:
FUNCTION arrayFn
VAR_IN_OUT
inOutArray: ARRAY[1..5] OF ARRAY[0..80] OF CHAR;
END_VAR
inOutArray[1][0] := 'V';
inOutArray[1][1] := 'a';
inOutArray[1][2] := 'l';
inOutArray[1][3] := 'u';
inOutArray[1][4] := 'e';
END_FUNCTION
FUNCTION main
VAR
localArray: ARRAY[1..5] OF ARRAY[0..80] OF CHAR;
END_VAR
arrayFn(inOutArray := localArray);
END_FUNCTION
error[E037]: Invalid assignment: cannot assign 'ARRAY[1..5] OF ARRAY[0..80] OF CHAR' to 'ARRAY[1..5] OF ARRAY[0..80] OF CHAR'
┌─ target/demo2.st:18:13
│
18 │ arrayFn(inOutArray := localArray);
│ ^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[1..5] OF ARRAY[0..80] OF CHAR' to 'ARRAY[1..5] OF ARRAY[0..80] OF CHAR'
Compilation aborted due to critical errors.
Hint: You can use `plc explain <ErrorCode>` for more information