#test to check if pass by ref and nested scopes work
#should output 522405324025
module main;

var w:int;
var z:int;

procedure foo(var x:int, y:int);

procedure bar(var x:int);
  begin  
    x := 5;
    output := x;
    output := y;
    output := w;
    output := z;
    output := 0;
  end bar;

  const z:int = 4;
  begin
    bar(x);
    y := 3;
    output := x;
    output := y;
    output := w;
    output := z;
    output := 0;
  end foo;

begin
  z := 1;
  w := 2;
  foo(z,w);

  output := w;
  output := z;

end main.