File tree Expand file tree Collapse file tree 5 files changed +34
-13
lines changed
src/compiler/ocaml_to_erlang
tests/compiler/expressions.t Expand file tree Collapse file tree 5 files changed +34
-13
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,20 @@ let ppf = Format.err_formatter
1111let file_a_bug =
1212 {| If you think this is a bug, please file an issue here : https :// github.com/ AbstractMachinesLab / caramel/ issues/ new |}
1313
14+ let unsupported_fallthrough_cases () =
15+ Format. fprintf ppf
16+ {| We have found a case expression that falls through to the next case, like :
17+
18+ match x with
19+ | 0 | 1 -> true < --- this branch falls through
20+ | _ -> false
21+
22+ Since these patterns are not possible in Erlang , Caramel does not support them
23+ at the moment .
24+ \n
25+ |};
26+ exit 1
27+
1428let unsupported_let_rec_inside_of_function_body () =
1529 Format. fprintf ppf
1630 {| We have found a let rec binding within a function .
Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ and mk_pattern :
125125 let value = mk_pattern expr ~var_names in
126126 Pat. tuple [ tag; value ]
127127 | Tpat_constant const -> Erlang.Ast. Pattern_match (const_to_literal const)
128+ | Tpat_or (_ , _ , _ ) -> Error. unsupported_fallthrough_cases ()
128129 (* NOTE: here's where the translation of pattern
129130 * matching at the function level should happen. *)
130131 | _ -> Erlang.Ast. Pattern_ignore
Original file line number Diff line number Diff line change @@ -37,8 +37,3 @@ let match_tuples () =
3737
3838let match_atoms () =
3939 match `Hello with `Xavier -> true | `Joe -> true | _ -> false
40-
41- let match_fall_through () =
42- match 0 with
43- | 1 | 2 -> true
44- | _ -> false
Original file line number Diff line number Diff line change 1+ let match_fall_through () =
2+ match 0 with
3+ | 1 | 2 -> true
4+ | _ -> false
Original file line number Diff line number Diff line change 88 list.ml
99 literals.ml
1010 match.ml
11+ match_fallthrough.ml
1112 names.ml
1213 names_primes.ml
1314 record_update.ml
381382 - export_type ([int_pair/ 0 ]).
382383
383384 - export ([match_atoms/ 0 ]).
384- - export ([match_fall_through/ 0 ]).
385385 - export ([match_ignore/ 0 ]).
386386 - export ([match_int/ 0 ]).
387387 - export ([match_list/ 0 ]).
459459 _ -> false
460460 end .
461461
462- - spec match_fall_through () -> boolean ().
463- match_fall_through () ->
464- case 0 of
465- _ -> true ;
466- _ -> false
467- end .
468-
469462
470463 $ caramelc compile names.ml
471464 File "names.ml" , line 15 , characters 2 - 13 :
629622 }.
630623
631624
625+ $ caramelc compile match_fallthrough.ml
626+ We have found a case expression that falls through to the next case, like:
627+
628+ match x with
629+ | 0 | 1 -> true < --- this branch falls through
630+ | _ -> false
631+
632+ Since these patterns are not possible in Erlang, Caramel does not support them
633+ at the moment.
634+ \n
635+ [1 ]
636+ $ cat match_fallthrough.erl
637+ cat: match_fallthrough.erl: No such file or directory
638+ [1 ]
You can’t perform that action at this time.
0 commit comments