Skip to content

Commit

Permalink
Merge pull request #1067 from lorchrob/assumption-global-const-bug
Browse files Browse the repository at this point in the history
Fix bug that erroneously disallowed refinement type assumptions from referencing global constants
  • Loading branch information
daniel-larraz committed May 8, 2024
2 parents 8d6f648 + 8fcb773 commit 1700919
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/lustre/lustreTypeChecker.ml
Expand Up @@ -1624,22 +1624,29 @@ and check_range_bound ctx e =
and check_ref_type_assumptions ctx src nname bound_var e =
let vars = LH.vars_without_node_call_ids_current e |> SI.elements in
let inputs = (match nname with
| Some nname -> lookup_node_param_attr ctx nname
| None -> None
| Some nname -> lookup_node_param_attr ctx nname
| None -> None
)
in
match src with
| Input -> (
(* Filter out variables that are inputs, bound variables,
or global constants. *)
let vars = List.filter (fun var ->
match inputs with
| None -> false
| Some inputs ->
not (List.mem var (List.map fst inputs)) && var != bound_var
) vars
| None -> false
| Some inputs ->
not (List.mem var (List.map fst inputs)) &&
var != bound_var
) vars |> List.filter (fun i ->
match lookup_const ctx i with
| Some (_, _, Global) -> false
| _ -> true
)
in
match vars with
| [] -> R.ok ()
| h :: _ -> (type_error (LH.pos_of_expr e) (AssumptionOnCurrentOutput h))
| [] -> R.ok ()
| h :: _ -> (type_error (LH.pos_of_expr e) (AssumptionOnCurrentOutput h))
)
| Output | Local | Ghost | Global -> R.ok ()

Expand Down
6 changes: 6 additions & 0 deletions tests/regression/success/assumption_on_global_const.lus
@@ -0,0 +1,6 @@
const c: int;

node N(x: int | x < c) returns ();
let
check true;
tel

0 comments on commit 1700919

Please sign in to comment.