Skip to content

GAZPREA: clarification on procedure argument aliasing #164

Open

Description

@r4nd0mus3rnam3
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions