diff --git a/src/passes/operators/operators.ml b/src/passes/operators/operators.ml
index ceb17f17a..47627a440 100644
--- a/src/passes/operators/operators.ml
+++ b/src/passes/operators/operators.ml
@@ -312,11 +312,12 @@ module Typer = struct
     then ok @@ t_bytes ()
     else simple_fail "bad slice"
 
-  let failwith_ = typer_1 "FAILWITH" @@ fun t ->
+  let failwith_ = typer_1_opt "FAILWITH" @@ fun t opt ->
     let%bind () =
       Assert.assert_true @@
       (is_t_string t) in
-    ok @@ t_unit ()
+    let default = t_unit () in
+    ok @@ Simple_utils.Option.unopt ~default opt
 
   let map_get_force = typer_2 "MAP_GET_FORCE" @@ fun i m ->
     let%bind (src, dst) = bind_map_or (get_t_map , get_t_big_map) m in
diff --git a/src/test/contracts/failwith.ligo b/src/test/contracts/failwith.ligo
index 5b1f6b6af..6a758b844 100644
--- a/src/test/contracts/failwith.ligo
+++ b/src/test/contracts/failwith.ligo
@@ -11,7 +11,7 @@ function main (const p : param; const s : unit) : list(operation) * unit is
   }
   with ((nil : list(operation)), s)
 
-function foobar (const i : int) : unit is
+function foobar (const i : int) : int is
   var p : param := Zero (42n) ;
   block {
     if i > 0 then block {
@@ -27,4 +27,7 @@ function foobar (const i : int) : unit is
       | Pos (n) -> skip
       end
     }
-  } with unit
+  } with case p of
+  | Zero (n) -> i
+  | Pos (n) -> (failwith ("waaaa") : int)
+  end
diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml
index 9c055964e..a2bc4197e 100644
--- a/src/test/integration_tests.ml
+++ b/src/test/integration_tests.ml
@@ -652,10 +652,10 @@ let failwith_ligo () : unit result =
   let%bind _ = should_work (e_pair (e_constructor "Pos" (e_nat 1)) (e_unit ())) in
   let%bind _ = should_fail (e_pair (e_constructor "Pos" (e_nat 0)) (e_unit ())) in
   let should_fail input = expect_fail program "foobar" (e_int input) in
-  let should_work input = expect_eq program "foobar" (e_int input) (e_unit ()) in
-  let%bind () = should_fail @@ 10 in
+  let should_work input n = expect_eq program "foobar" (e_int input) (e_int n) in
+  let%bind () = should_fail 10 in
   let%bind () = should_fail @@ -10 in
-  let%bind () = should_work @@ 5 in
+  let%bind () = should_work 5 6 in
   ok ()
 
 let failwith_mligo () : unit result =