diff --git a/src/construct.ml b/src/construct.ml index 5df03cdc4d4..507d40907f7 100644 --- a/src/construct.ml +++ b/src/construct.ml @@ -509,3 +509,7 @@ let forE pat exp1 exp2 = ) ) ) + +let unreachableE = + (* Do we want UnreachableE in the AST *) + loopE unitE diff --git a/src/construct.mli b/src/construct.mli index 2ecedc6e42f..2ab8c1be489 100644 --- a/src/construct.mli +++ b/src/construct.mli @@ -73,6 +73,8 @@ val declare_idE : id -> typ -> exp -> exp val define_idE : id -> mut -> exp -> exp val newObjE : obj_sort -> Ir.field list -> typ -> exp +val unreachableE : exp + (* Declarations *) val letP : pat -> exp -> dec diff --git a/src/desugar.ml b/src/desugar.ml index cc65f9958ff..34351775b33 100644 --- a/src/desugar.ml +++ b/src/desugar.ml @@ -72,9 +72,13 @@ and exp' at note = function let args, wrap = to_args cc p in I.FuncE (name, cc, typ_binds tbs, args, Type.as_seq ty.note, wrap (exp e)) | S.CallE (e1, inst, e2) -> - let cc = Value.call_conv_of_typ e1.Source.note.S.note_typ in - let inst = List.map (fun t -> t.Source.note) inst in - I.CallE (cc, exp e1, inst, exp e2) + let t = e1.Source.note.S.note_typ in + if Type.is_non t + then unreachableE.it + else + let cc = Value.call_conv_of_typ t in + let inst = List.map (fun t -> t.Source.note) inst in + I.CallE (cc, exp e1, inst, exp e2) | S.BlockE [] -> I.TupE [] | S.BlockE [{it = S.ExpD e; _}] -> (exp e).it | S.BlockE ds -> I.BlockE (block (Type.is_unit note.S.note_typ) ds) diff --git a/src/type.ml b/src/type.ml index c4e728f1d08..44a193872ba 100644 --- a/src/type.ml +++ b/src/type.ml @@ -294,6 +294,7 @@ let rec promote = function (* Projections *) +let is_non = function Non -> true | _ -> false let is_prim p = function Prim p' -> p = p' | _ -> false let is_obj = function Obj _ -> true | _ -> false let is_variant = function Variant _ -> true | _ -> false diff --git a/src/type.mli b/src/type.mli index 8059e530e3f..c0c6593a8e8 100644 --- a/src/type.mli +++ b/src/type.mli @@ -65,6 +65,7 @@ val prim : string -> prim (* Projection *) +val is_non : typ -> bool val is_prim : prim -> typ -> bool val is_obj : typ -> bool val is_variant : typ -> bool diff --git a/test/run/ok/call-none.diff-ir.ok b/test/run/ok/call-none.diff-ir.ok deleted file mode 100644 index e38b33ed0a4..00000000000 --- a/test/run/ok/call-none.diff-ir.ok +++ /dev/null @@ -1,66 +0,0 @@ ---- call-none.run -+++ call-none.run-ir -@@ -0,0 +1,63 @@ -+prelude:200.1-225.2: internal error, Invalid_argument("call_conv_of_typ Non") -+ -+Last environment: -+@new_async = func -+@text_of_Bool = func -+@text_of_Int = func -+@text_of_Nat = func -+@text_of_Text = func -+@text_of_array = func -+@text_of_array_mut = func -+@text_of_option = func -+@text_of_variant = func -+Array_init = func -+Array_tabulate = func -+abs = func -+btstWord16 = func -+btstWord32 = func -+btstWord64 = func -+btstWord8 = func -+charToText = func -+charToWord32 = func -+clzWord16 = func -+clzWord32 = func -+clzWord64 = func -+clzWord8 = func -+ctzWord16 = func -+ctzWord32 = func -+ctzWord64 = func -+ctzWord8 = func -+decodeUTF8 = func -+hashInt = func -+ignore = func -+intToWord16 = func -+intToWord32 = func -+intToWord64 = func -+intToWord8 = func -+natToWord16 = func -+natToWord32 = func -+natToWord64 = func -+natToWord8 = func -+popcntWord16 = func -+popcntWord32 = func -+popcntWord64 = func -+popcntWord8 = func -+print = func -+printChar = func -+printInt = func -+range = func -+revrange = func -+shrsWord16 = func -+shrsWord32 = func -+shrsWord64 = func -+shrsWord8 = func -+word16ToInt = func -+word16ToNat = func -+word32ToChar = func -+word32ToInt = func -+word32ToNat = func -+word64ToInt = func -+word64ToNat = func -+word8ToInt = func -+word8ToNat = func -+ diff --git a/test/run/ok/call-none.diff-low.ok b/test/run/ok/call-none.diff-low.ok deleted file mode 100644 index d33919f704f..00000000000 --- a/test/run/ok/call-none.diff-low.ok +++ /dev/null @@ -1,66 +0,0 @@ ---- call-none.run -+++ call-none.run-low -@@ -0,0 +1,63 @@ -+prelude:200.1-225.2: internal error, Invalid_argument("call_conv_of_typ Non") -+ -+Last environment: -+@new_async = func -+@text_of_Bool = func -+@text_of_Int = func -+@text_of_Nat = func -+@text_of_Text = func -+@text_of_array = func -+@text_of_array_mut = func -+@text_of_option = func -+@text_of_variant = func -+Array_init = func -+Array_tabulate = func -+abs = func -+btstWord16 = func -+btstWord32 = func -+btstWord64 = func -+btstWord8 = func -+charToText = func -+charToWord32 = func -+clzWord16 = func -+clzWord32 = func -+clzWord64 = func -+clzWord8 = func -+ctzWord16 = func -+ctzWord32 = func -+ctzWord64 = func -+ctzWord8 = func -+decodeUTF8 = func -+hashInt = func -+ignore = func -+intToWord16 = func -+intToWord32 = func -+intToWord64 = func -+intToWord8 = func -+natToWord16 = func -+natToWord32 = func -+natToWord64 = func -+natToWord8 = func -+popcntWord16 = func -+popcntWord32 = func -+popcntWord64 = func -+popcntWord8 = func -+print = func -+printChar = func -+printInt = func -+range = func -+revrange = func -+shrsWord16 = func -+shrsWord32 = func -+shrsWord64 = func -+shrsWord8 = func -+word16ToInt = func -+word16ToNat = func -+word32ToChar = func -+word32ToInt = func -+word32ToNat = func -+word64ToInt = func -+word64ToNat = func -+word8ToInt = func -+word8ToNat = func -+ diff --git a/test/run/ok/call-none.run-ir.ok b/test/run/ok/call-none.run-ir.ok deleted file mode 100644 index 30afb5f4fe4..00000000000 --- a/test/run/ok/call-none.run-ir.ok +++ /dev/null @@ -1,63 +0,0 @@ -prelude:200.1-225.2: internal error, Invalid_argument("call_conv_of_typ Non") - -Last environment: -@new_async = func -@text_of_Bool = func -@text_of_Int = func -@text_of_Nat = func -@text_of_Text = func -@text_of_array = func -@text_of_array_mut = func -@text_of_option = func -@text_of_variant = func -Array_init = func -Array_tabulate = func -abs = func -btstWord16 = func -btstWord32 = func -btstWord64 = func -btstWord8 = func -charToText = func -charToWord32 = func -clzWord16 = func -clzWord32 = func -clzWord64 = func -clzWord8 = func -ctzWord16 = func -ctzWord32 = func -ctzWord64 = func -ctzWord8 = func -decodeUTF8 = func -hashInt = func -ignore = func -intToWord16 = func -intToWord32 = func -intToWord64 = func -intToWord8 = func -natToWord16 = func -natToWord32 = func -natToWord64 = func -natToWord8 = func -popcntWord16 = func -popcntWord32 = func -popcntWord64 = func -popcntWord8 = func -print = func -printChar = func -printInt = func -range = func -revrange = func -shrsWord16 = func -shrsWord32 = func -shrsWord64 = func -shrsWord8 = func -word16ToInt = func -word16ToNat = func -word32ToChar = func -word32ToInt = func -word32ToNat = func -word64ToInt = func -word64ToNat = func -word8ToInt = func -word8ToNat = func - diff --git a/test/run/ok/call-none.run-low.ok b/test/run/ok/call-none.run-low.ok deleted file mode 100644 index 30afb5f4fe4..00000000000 --- a/test/run/ok/call-none.run-low.ok +++ /dev/null @@ -1,63 +0,0 @@ -prelude:200.1-225.2: internal error, Invalid_argument("call_conv_of_typ Non") - -Last environment: -@new_async = func -@text_of_Bool = func -@text_of_Int = func -@text_of_Nat = func -@text_of_Text = func -@text_of_array = func -@text_of_array_mut = func -@text_of_option = func -@text_of_variant = func -Array_init = func -Array_tabulate = func -abs = func -btstWord16 = func -btstWord32 = func -btstWord64 = func -btstWord8 = func -charToText = func -charToWord32 = func -clzWord16 = func -clzWord32 = func -clzWord64 = func -clzWord8 = func -ctzWord16 = func -ctzWord32 = func -ctzWord64 = func -ctzWord8 = func -decodeUTF8 = func -hashInt = func -ignore = func -intToWord16 = func -intToWord32 = func -intToWord64 = func -intToWord8 = func -natToWord16 = func -natToWord32 = func -natToWord64 = func -natToWord8 = func -popcntWord16 = func -popcntWord32 = func -popcntWord64 = func -popcntWord8 = func -print = func -printChar = func -printInt = func -range = func -revrange = func -shrsWord16 = func -shrsWord32 = func -shrsWord64 = func -shrsWord8 = func -word16ToInt = func -word16ToNat = func -word32ToChar = func -word32ToInt = func -word32ToNat = func -word64ToInt = func -word64ToNat = func -word8ToInt = func -word8ToNat = func - diff --git a/test/run/ok/call-none.wasm.stderr.ok b/test/run/ok/call-none.wasm.stderr.ok deleted file mode 100644 index 30afb5f4fe4..00000000000 --- a/test/run/ok/call-none.wasm.stderr.ok +++ /dev/null @@ -1,63 +0,0 @@ -prelude:200.1-225.2: internal error, Invalid_argument("call_conv_of_typ Non") - -Last environment: -@new_async = func -@text_of_Bool = func -@text_of_Int = func -@text_of_Nat = func -@text_of_Text = func -@text_of_array = func -@text_of_array_mut = func -@text_of_option = func -@text_of_variant = func -Array_init = func -Array_tabulate = func -abs = func -btstWord16 = func -btstWord32 = func -btstWord64 = func -btstWord8 = func -charToText = func -charToWord32 = func -clzWord16 = func -clzWord32 = func -clzWord64 = func -clzWord8 = func -ctzWord16 = func -ctzWord32 = func -ctzWord64 = func -ctzWord8 = func -decodeUTF8 = func -hashInt = func -ignore = func -intToWord16 = func -intToWord32 = func -intToWord64 = func -intToWord8 = func -natToWord16 = func -natToWord32 = func -natToWord64 = func -natToWord8 = func -popcntWord16 = func -popcntWord32 = func -popcntWord64 = func -popcntWord8 = func -print = func -printChar = func -printInt = func -range = func -revrange = func -shrsWord16 = func -shrsWord32 = func -shrsWord64 = func -shrsWord8 = func -word16ToInt = func -word16ToNat = func -word32ToChar = func -word32ToInt = func -word32ToNat = func -word64ToInt = func -word64ToNat = func -word8ToInt = func -word8ToNat = func -