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

Tracking differences between melc and ocamlc, for cmi generation #346

Open
jchavarri opened this issue Oct 14, 2022 · 0 comments
Open

Tracking differences between melc and ocamlc, for cmi generation #346

jchavarri opened this issue Oct 14, 2022 · 0 comments

Comments

@jchavarri
Copy link
Member

This issue tracks the differences between melc internals and ocamlc. One of the goals is to be able to compile Melange cmi files directly with ocamlc —and maybe cmt—.

Note: strict removals of functionality in Melange / ReScript (like removal of Printf) do not affect this goal, as the idea is to build Melange code with OCaml compiler (not the other way around), so for now they are excluded from the list.

List (ongoing, non-exhaustive)

1. Melange externals can be defined with non-function types

Melange allows defining externals like external foo: string = "foo", which is invalid in ocamlc, e.g.:

File "node_modules/reason-react/src/legacy/ReactEventRe.rei", line 32, characters 27-31:
32 |   external preventDefault: unit = "preventDefault";
                                ^^^^
Error: External identifiers must be functions

Fixing this issue exclusively on Melange side (i.e. without changing the way ocamlc works) would involve breaking the ecosystem of bindings and libraries in some way.

2. Melange injects some marshalled-encoded info in externals

Melange injects some marshalled data into externals when processing the ast:

pval_prim = [prim_name; External_ffi_types.to_string ffi];

This breaks when using ocamlc to generate cmis:

Values do not match:
    external bubbles : 'a synthetic -> bool = "bubbles" "BS:external"
is not included in
    external bubbles : 'a synthetic -> bool = "bubbles"
The native names of the primitives are not the same
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

No branches or pull requests

1 participant