Skip to content

Commit

Permalink
Correctly consume array accesses
Browse files Browse the repository at this point in the history
  • Loading branch information
rachitnigam committed Sep 18, 2018
1 parent 1837ac8 commit cbe1fcc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ and check_aa id idx_exprs c : type_node * gamma =
let unrollf = compute_unrollf idx_exprs c in
if (bf mod unrollf)=0 then
try
let banks = Core.List.range 0 (unrollf-1) in
let banks = Core.List.range 0 unrollf in
t, (Context.consume_aa_lst id banks c)
with AlreadyConsumed bank -> raise @@ TypeError (illegal_bank bank id)
else
Expand Down
5 changes: 5 additions & 0 deletions test/type_failures.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ let%expect_test "Cannot reassign to different type" =
[Type Error] cannot assign value of type `idx<1 .. 2, 0 .. 1>' to L-value of type `float' |}]
;;

let%expect_test "Cannot use array twice" =
compile_string_with_failure "func foo(a: int[10]) { let x = a[1]; let y = a[1]; }";
[%expect {|
[Type Error] cannot assign value of type `idx<1 .. 2, 0 .. 1>' to L-value of type `float' |}]
;;

0 comments on commit cbe1fcc

Please sign in to comment.