Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playground: reason syntax and react ppx #602

Merged
merged 47 commits into from
Jun 21, 2023
Merged

playground: reason syntax and react ppx #602

merged 47 commits into from
Jun 21, 2023

Conversation

jchavarri
Copy link
Member

@jchavarri jchavarri commented Jun 2, 2023

Based on #538, continues the work from there to add:

  • Integration with reason syntax
  • reactjs ppx
  • removes special handling for stdlib, so packages like melange.belt are required as if they were in node_modules
  • investigate issue with reason parser choking on // input
  • issue with errors without locations (playground: reason syntax and react ppx #602 (comment))

@jchavarri
Copy link
Member Author

jchavarri commented Jun 2, 2023

@anmonteiro I am running into some issue with errors from ppxlib, where the locations are missing for some reason.

Repro:

$ make dev
$ find _build/default/jscomp/stdlib/.stdlib.objs/melange -name "*.cmi" -or -name "*.cmj" | xargs js_of_ocaml build-fs -o stdlib.js
$ make playground-dev
$ node
Welcome to Node.js v18.16.0.
Type ".help" for more information.
> require('./_build/default/bin/jsoo_main.bc.js'); require('./stdlib.js');
{}
> ocaml.compile("let t = [%bs.obj 2]");
{ js_error_msg: 'Expect a record expression here' }

The problem seems to be that Location.error_of_exn returns None for this error, do you have any clues? I tried removing the code added in #590, but nothing changed.

@@ -86,7 +85,11 @@ module Reason = struct
(* you can't throw an Error here. jsoo parses the string and turns it
into something else *)
let throwAnything = Js.Unsafe.js_expr "function(a) {throw a}" in
try code |> Js.to_string |> Lexing.from_string |> f
let code =
(* Add ending new line as otherwise reason parser chokes with inputs such as "//" *)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this reasonml/reason#2350, which was fixed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like. I have no idea why it's reappearing now, maybe because in playground case we don't have EOF?

Base automatically changed from playground-1 to main June 5, 2023 23:43
@jchavarri jchavarri marked this pull request as ready for review June 6, 2023 13:27
@jchavarri jchavarri requested a review from anmonteiro June 6, 2023 13:29
@jchavarri
Copy link
Member Author

jchavarri commented Jun 6, 2023

This is ready, the only thing I could not figure out is why when there are errors coming from melange ppx, the line locations are gone (asked above).

@anmonteiro
Copy link
Member

mystery solved 1b89c2f

Copy link
Member

@anmonteiro anmonteiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to depend on Reason 3.9 before we merge this (see ocaml/opam-repository#23945).

That release ports Reason to ppxlib and breaks the current interface file signature.

@jchavarri
Copy link
Member Author

mystery solved 1b89c2f

Thanks!

I'd like to depend on Reason 3.9 before we merge this (see ocaml/opam-repository#23945).

Sounds good.

let make_compiler name impl =
export name
let () =
export "ocaml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we should call this melange.

feel free to do in a future PR, I don't want to unblock this one further

@anmonteiro anmonteiro merged commit a8f6333 into main Jun 21, 2023
@anmonteiro anmonteiro deleted the playground-2 branch June 21, 2023 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants