Skip to content

Commit

Permalink
Fix array access with subrange index
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-larraz committed Aug 7, 2023
1 parent 30de6ec commit 3272128
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/lustre/lustreExpr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3562,8 +3562,7 @@ let type_of_select = function

(function t ->

(* Second argument must match index type of array *)
if Type.check_type (Type.index_type_of_array s) t then
if (Type.is_int t || Type.is_int_range t) then

(* Return type of array elements *)
Type.elem_type_of_array s
Expand Down Expand Up @@ -3605,8 +3604,7 @@ let type_of_store = function

(fun i v ->

(* Second argument must match index type of array *)
if Type.check_type i (Type.index_type_of_array s) &&
if (Type.is_int i || Type.is_int_range i) &&
Type.check_type (Type.elem_type_of_array s) v
then

Expand Down
8 changes: 8 additions & 0 deletions tests/regression/success/array-subrange-index.lus
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

type I = subrange [0,1] of int;

node N(j: I) returns (B: int^2)
let
B[i] = 0;
check B[j]=0;
tel

0 comments on commit 3272128

Please sign in to comment.