-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix nested object get and set not working in res files (#533)
* test: add repro for 489 * test: fix dune file for gh489 * ppx_rescript_compat: process nested pexp_send * test: add rescript-syntax to gh489 * add applies_to * disable rescript-syntax tests * add rescript-syntax test to melange package * Revert "add rescript-syntax test to melange package" This reverts commit e2073f8. * fix rescript-syntax tests * cleanup * more cleanup * add one more level to rescript test
- Loading branch information
Showing
4 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(cram | ||
(package rescript-syntax) | ||
(deps %{bin:melc} %{bin:rescript_syntax})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Repro for GitHub issue 489, first try setting values in nested objects with OCaml syntax | ||
|
||
$ cat > foo.ml <<EOF | ||
> type person = < age :int [@bs.set ] > Js.t | ||
> type entry = < person :person [@bs.set ] > Js.t | ||
> external entry : entry = "entry"[@@bs.val ] | ||
> let () = ((entry ## person) ## age) #= 99 | ||
> EOF | ||
$ melc foo.ml | ||
// Generated by Melange | ||
'use strict'; | ||
entry.person.age = 99; | ||
/* Not a pure module */ | ||
Now let's try with ReScript syntax | ||
$ cat > foo.res <<EOF | ||
> type person = {@set "age": int} | ||
> type entry = {@set "person": person} | ||
> type deep = {@set "deep": entry} | ||
> @val external deep: deep = "deep" | ||
> deep["deep"]["person"]["age"] = 99 | ||
$ rescript_syntax -print=ml foo.res | ||
type nonrec person = < age: int [@set ] > Js.t | ||
type nonrec entry = < person: person [@set ] > Js.t | ||
type nonrec deep = < deep: entry [@set ] > Js.t | ||
external deep : deep = "deep"[@@val ] | ||
;;(((deep ## deep) ## person) ## age) #= 99 | ||
$ rescript_syntax -print=ml foo.res > foo.ml | ||
$ melc foo.ml | ||
// Generated by Melange | ||
'use strict'; | ||
deep.deep.person.age = 99; | ||
/* Not a pure module */ |