LexiFi / gen_js_api

Easy OCaml bindings for Javascript libraries
MIT License
177 stars 31 forks source link

js.* attributes on val declarations fail to compile in 1.0.7 #148

Closed mnxn closed 3 years ago

mnxn commented 3 years ago

For vscode-ocaml-platform, we used [@@js.*] attributes on val declarations in implementation files that are described in PPX.md.

After trying to update to 1.0.7, the val declarations stopped compiling. The example in PPX.md has the following error:

1 | val alert_bool : bool -> unit [@@js.global "alert"]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Value declarations are only allowed in signatures

In 1.0.6, this compiled without errors. As a workaround, each block of val declarations can be wrapped in include [%js: ... ], but that makes the code much messier when mixed with normal OCaml functions.

smorimoto commented 3 years ago

@mlasson Is this behaviour what we expect?

mlasson commented 3 years ago

@mnxn @smorimoto Yes, unfortunately, you are right; you now need to wrapped them in [%js: ...] extension; this change was introduced for compatibility with ppxlib which does not allow that . We should fix the documentation though.

smorimoto commented 3 years ago

Got it. Thanks!