Skip to content

Commit 38e45b3

Browse files
committed
Fixes #283: ppx_op: allow field deref for inline dim spec, allow type spec for the ~config param
1 parent 5c04afc commit 38e45b3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/ppx_op.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ let rec translate ~has_config ?ident_label expr =
108108
[%e? { pexp_desc = Pexp_constant (Pconst_string (ident, str_loc, _)); _ } as s]
109109
[%e?
110110
( { pexp_desc = Pexp_constant (Pconst_integer _); pexp_loc = dims_loc; _ }
111-
| { pexp_desc = Pexp_ident _; pexp_loc = dims_loc; _ } ) as d]] ->
111+
| { pexp_desc = Pexp_ident _; pexp_loc = dims_loc; _ }
112+
| { pexp_desc = Pexp_field _; pexp_loc = dims_loc; _ } ) as d]] ->
112113
let pat, vb = make_vb_dims ~has_config ~loc ~str_loc ~ident ~dims:[ d ] ~dims_loc s in
113114
(Map.singleton (module String) ident vb, pat2expr pat)
114115
| [%expr
@@ -156,6 +157,9 @@ let rec translate ~has_config ?ident_label expr =
156157
| [%expr fun ~config -> [%e? body]] ->
157158
let vbs, body = translate ~has_config:true ?ident_label body in
158159
(no_vbs, [%expr fun ~config -> [%e let_opt ~loc vbs body]])
160+
| [%expr fun ~(config : [%typ? config_ty]) -> [%e? body]] ->
161+
let vbs, body = translate ~has_config:true ?ident_label body in
162+
(no_vbs, [%expr fun ~(config : [%typ ty]) -> [%e let_opt ~loc vbs body]])
159163
| [%expr fun [%p? pat] -> [%e? body]] ->
160164
let vbs, body = loop ?ident_label body in
161165
(vbs, [%expr fun [%p pat] -> [%e body]])

0 commit comments

Comments
 (0)