Skip to content

Commit

Permalink
Remove incorrect invariant for [Apply] (ocaml-flambda#1239)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gbury authored Mar 20, 2023
1 parent bf48415 commit a1e5e7c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
13 changes: 2 additions & 11 deletions middle_end/flambda2/terms/apply_expr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ let [@ocamlformat "disable"] print ppf

let invariant
({ callee;
continuation;
continuation = _;
exn_continuation = _;
args;
args_arity;
Expand Down Expand Up @@ -171,16 +171,7 @@ let invariant
<> 0
then
Misc.fatal_errorf
"Length of argument and arity lists disagree in [Apply]:@ %a" print t;
match continuation with
| Never_returns ->
if not (Flambda_arity.With_subkinds.is_nullary return_arity)
then
Misc.fatal_errorf
"This [Apply] never returns and so should have a nullary return arity, \
but instead has a return arity of %a:@ %a"
Flambda_arity.With_subkinds.print return_arity print t
| Return _ -> ()
"Length of argument and arity lists disagree in [Apply]:@ %a" print t

let create ~callee ~continuation exn_continuation ~args ~args_arity
~return_arity ~(call_kind : Call_kind.t) dbg ~inlined ~inlining_state
Expand Down
10 changes: 10 additions & 0 deletions middle_end/flambda2/tests/mlexamples/function_never_returns.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(* compiled with -flambda2-result-types-all-functions this used to trigger a
compilation error related to [Never_returns] functions and return arity. *)

let[@inline never] f () : unit = raise Exit

let foo x =
let () = f () in
x + 1

let bar x = (foo [@inlined]) x

0 comments on commit a1e5e7c

Please sign in to comment.