Skip to content

Commit

Permalink
ppx_rescript_compat: process nested pexp_send
Browse files Browse the repository at this point in the history
  • Loading branch information
jchavarri committed Mar 30, 2023
1 parent 24f59f1 commit ef79a3b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion rescript-syntax/ppx_rescript_compat/ppx_rescript_compat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ let expr_mapper (self : mapper) (expr : Parsetree.expression) =
Melange_ppx.Ast_uncurry_apply.property_apply loc self obj name args;
}
| Pexp_send
( ({ pexp_desc = Pexp_apply _ | Pexp_ident _; pexp_loc; _ } as subexpr),
( ({ pexp_desc = Pexp_apply _ | Pexp_ident _ | Pexp_send _; pexp_loc; _ } as subexpr),
arg ) ->
(* ReScript removed the OCaml object system and abuses `Pexp_send` for
`obj##property`. Here, we make that conversion. *)
let subexpr = self.expr self subexpr in
{
expr with
pexp_desc =
Expand Down
13 changes: 8 additions & 5 deletions test/gh489.t
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ Now let's try with ReScript syntax
type nonrec person = < age: int [@set ] > Js.t
type nonrec entry = < person: person [@set ] > Js.t
external entry : entry = "entry"[@@val ]
;;(entry ## person)#age #= 99
;;((entry ## person) ## age) #= 99
$ rescript_syntax -print=ml foo.res > foo.ml
$ melc foo.ml
melc: internal error, uncaught exception:
File "jscomp/frontend/ast_exp_apply.ml", line 252, characters 17-23: Assertion failed
[125]
// Generated by Melange
'use strict';
entry.person.age = 99;
/* Not a pure module */

0 comments on commit ef79a3b

Please sign in to comment.