raz / test / run / SliceRegsCheck.raz

21 lines · 418 B · raw · history · last change e224225d

1(* A failed check of an index into a slice in registers says the
2 length, read from its register. *)
3module SliceRegsCheck;
4import Out;
5
6proc squares(s: []INT; n: INT): INT;
7var i, t: INT;
8begin
9 for i := 0 to n do t := t + s[i] * s[i]; end;
10 return t;
11end;
12
13proc main*;
14var x: [3]INT;
15begin
16 x := [1, 2, 3];
17 Out.int(squares(x, 2)); Out.ln;
18 Out.int(squares(x, 3)); Out.ln;
19end;
20
21end SliceRegsCheck.