You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GAZPREA: clarification on procedure argument aliasing #164
procedure display(integer a, integer b) {
a + b -> std_output;
}
procedure main() returns integer {
var integer x = 5;
call display(x, x);
return 0;
}
should the above code be illegal?
there's a section in the spec that's relevant here:
This program is ill-formed; the compiler must reject it (AliasingError).
The same shape of call is legal when every aliased argument is bound to a const parameter, since neither can be mutated:
procedure p(var integer a, var integer b, const integer c, const integer d) {
/* Some code here */
}
procedure main() returns integer {
var integer x = 0;
var integer y = 0;
var integer z = 0;
/* Even though 'z' is aliased with 'c' and 'd' they are both const. */
call p(x, y, z, z);
return 0;
}
currently, the reference compiler lets this compile and run
Activity