File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -55,14 +55,14 @@ let transformation ctx =
55
55
let e_ext, acc = super#expression e_ext acc in
56
56
let make_transformations ~mode ~opts ~loc = function
57
57
| Pexp_function cases ->
58
- let cases, bindings = Transformations. transform_cases ~mode ~opts ~loc ~ctx cases in
59
- [% expr fun _ppx_regexp_v -> [% e cases]], bindings @ acc
58
+ let cases, binding = Transformations. transform_cases ~mode ~opts ~loc ~ctx cases in
59
+ [% expr fun _ppx_regexp_v -> [% e cases]], binding :: acc
60
60
| Pexp_match (e , cases ) ->
61
- let cases, bindings = Transformations. transform_cases ~mode ~opts ~loc ~ctx cases in
61
+ let cases, binding = Transformations. transform_cases ~mode ~opts ~loc ~ctx cases in
62
62
( [% expr
63
63
let _ppx_regexp_v = [% e e] in
64
64
[% e cases]],
65
- bindings @ acc )
65
+ binding :: acc )
66
66
| _ -> Util. error ~loc " [%%pcre] and [%%mik] only apply to match, function and global let declarations of strings."
67
67
in
68
68
match e_ext.pexp_desc with
Original file line number Diff line number Diff line change @@ -167,7 +167,11 @@ let make_default_rhs ~loc = function
167
167
| _ -> case)
168
168
default_cases
169
169
in
170
- pexp_match ~loc [% expr _ppx_regexp_v] transformed
170
+ match transformed with
171
+ | [{ pc_lhs = { ppat_desc = Ppat_any ; _ }; pc_guard = None ; pc_rhs; _ }] ->
172
+ pc_rhs
173
+ | _ ->
174
+ pexp_match ~loc [% expr _ppx_regexp_v] transformed
171
175
172
176
let transform_let ~mode ~ctx =
173
177
let parser = match mode with `Pcre -> Regexp. parse_exn ~target: `Let | `Mik -> Regexp. parse_mik_exn ~target: `Let in
@@ -316,7 +320,7 @@ let transform_cases ~mode ~opts ~loc ~ctx cases =
316
320
[% expr match [% e dispatchers] with Some result -> result | None -> [% e default_rhs]]
317
321
handlers]]
318
322
in
319
- [ % expr [ % e match_expr]], [ re_binding ]
323
+ match_expr, re_binding
320
324
321
325
(* processes each case individually instead of combining them into one RE *)
322
326
let transform_mixed_match ~loc ~ctx ?matched_expr cases acc =
You can’t perform that action at this time.
0 commit comments