Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensional array equality bug fix #1028

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/lustre/lustreAstHelpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ let rec expr_contains_call = function
| Call (_, _, _) | Condact (_, _, _, _, _, _) | RestartEvery (_, _, _, _) | ChooseOp (_, _, _, _)
-> true

let rec type_contains_array = function
| IntRange _ -> false
| TupleType (_, tys) | GroupType (_, tys) ->
List.fold_left (fun acc ty -> acc || type_contains_array ty) false tys
| RecordType (_, _, tys) ->
List.fold_left (fun acc (_, _, ty) -> acc || type_contains_array ty)
false tys
| ArrayType _ -> true
| _ -> false

let rec type_contains_subrange = function
| IntRange _ -> true
| TupleType (_, tys) | GroupType (_, tys) ->
Expand Down
3 changes: 3 additions & 0 deletions src/lustre/lustreAstHelpers.mli
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ val type_arity : lustre_type -> int * int
val type_contains_subrange : lustre_type -> bool
(** Returns true if the lustre type expression contains an IntRange or if it is an IntRange *)

val type_contains_array : lustre_type -> bool
(** Returns true if the lustre type expression contains an array or if it is an array *)

val substitute_naive : HString.t -> expr -> expr -> expr
(** Substitute second param for first param in third param.
ChooseOp and Quantifier are not supported due to introduction of bound variables. *)
Expand Down
2 changes: 1 addition & 1 deletion src/lustre/lustreTypeChecker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ and infer_type_comp_op: tc_context -> Lib.position -> LA.expr -> LA.expr
match op with
| Neq | Eq ->
R.ifM (eq_lustre_type ctx ty1 ty2)
(if LH.is_type_array ty1 then
(if LH.type_contains_array ty1 then
type_error pos (Unsupported "Extensional array equality is not supported")
else
R.ok (LA.Bool pos)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node N() returns(A: [int^2^3, int]);
let
check (A = pre A);
--%MAIN;
tel
4 changes: 4 additions & 0 deletions tests/ounit/lustre/testLustreFrontend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@ let _ = run_test_tt_main ("frontend LustreTypeChecker error tests" >::: [
match load_file "./lustreTypeChecker/extensional_array_equality.lus" with
| Error (`LustreTypeCheckerError (_, Unsupported _)) -> true
| _ -> false);
mk_test "test extensional array equality 2" (fun () ->
match load_file "./lustreTypeChecker/extensional_array_equality2.lus" with
| Error (`LustreTypeCheckerError (_, Unsupported _)) -> true
| _ -> false);
mk_test "test expected record type" (fun () ->
match load_file "./lustreTypeChecker/expected_record_type.lus" with
| Error (`LustreTypeCheckerError (_, ExpectedRecordType _)) -> true
Expand Down