reason icon indicating copy to clipboard operation
reason copied to clipboard

Invalid code generated from valid OCaml interface code

Open jchavarri opened this issue 6 years ago • 5 comments
trafficstars

Input (interface file):

val foo: int
[@@a val bar: string [@@b]]

Output:

[@a [@b] external bar: string = ]
let foo: int;

I believe the output should be:

[@a [@b] let bar: string; ]
let foo: int;

Version: Reason 3.5.0 @ 8ee1ff66

jchavarri avatar Sep 01 '19 21:09 jchavarri

I think this is a duplicate of https://github.com/facebook/reason/issues/2430, although a better / more minimal repro.

anmonteiro avatar Sep 02 '19 01:09 anmonteiro

@anmonteiro Ah yeah, it definitely is, I was also using gen_js_api 😄 Feel free to close it as duplicate 👍

jchavarri avatar Sep 02 '19 06:09 jchavarri

I ended up coding my bindings in pure ocaml due to this issue, and the fact that gen_js_api does not support reason natively and additional rules with reftm were awkward.

Lupus avatar Sep 02 '19 10:09 Lupus

and the fact that gen_js_api does not support reason natively

@Lupus The gen_js_api ppx should work out of the box, no? For the binary applied to interface files, I ended up finding a dune rule that works fine.

The only stopper for Reason syntax in gen_js_api that I can see at the moment is this issue :)

jchavarri avatar Sep 02 '19 11:09 jchavarri

Neat! My dune-fu is not so strong, I'll leverage this approach once the issue is fixed :)

Lupus avatar Sep 02 '19 12:09 Lupus