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
11
11
let file_a_bug =
12
12
{| If you think this is a bug, please file an issue here : https :// github.com/ AbstractMachinesLab / caramel/ issues/ new |}
13
13
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
+
14
28
let unsupported_let_rec_inside_of_function_body () =
15
29
Format. fprintf ppf
16
30
{| 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 :
125
125
let value = mk_pattern expr ~var_names in
126
126
Pat. tuple [ tag; value ]
127
127
| Tpat_constant const -> Erlang.Ast. Pattern_match (const_to_literal const)
128
+ | Tpat_or (_ , _ , _ ) -> Error. unsupported_fallthrough_cases ()
128
129
(* NOTE: here's where the translation of pattern
129
130
* matching at the function level should happen. *)
130
131
| _ -> Erlang.Ast. Pattern_ignore
Original file line number Diff line number Diff line change @@ -37,8 +37,3 @@ let match_tuples () =
37
37
38
38
let match_atoms () =
39
39
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 8
8
list.ml
9
9
literals.ml
10
10
match.ml
11
+ match_fallthrough.ml
11
12
names.ml
12
13
names_primes.ml
13
14
record_update.ml
381
382
- export_type ([int_pair/ 0 ]).
382
383
383
384
- export ([match_atoms/ 0 ]).
384
- - export ([match_fall_through/ 0 ]).
385
385
- export ([match_ignore/ 0 ]).
386
386
- export ([match_int/ 0 ]).
387
387
- export ([match_list/ 0 ]).
459
459
_ -> false
460
460
end .
461
461
462
- - spec match_fall_through () -> boolean ().
463
- match_fall_through () ->
464
- case 0 of
465
- _ -> true ;
466
- _ -> false
467
- end .
468
-
469
462
470
463
$ caramelc compile names.ml
471
464
File "names.ml" , line 15 , characters 2 - 13 :
629
622
}.
630
623
631
624
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