melange-re / melange

A mixture of tooling combined to produce JavaScript from OCaml & Reason
https://melange.re
Other
800 stars 50 forks source link

OCaml 5.2 support #1071

Closed kit-ty-kate closed 5 months ago

kit-ty-kate commented 6 months ago

The current version of melange fails with the following error when using OCaml 5.2:

#=== ERROR while compiling melange.3.0.0-51 ===================================#
# context              2.2.0~beta2~dev | linux/x86_64 | ocaml-variants.5.2.0+trunk | file:///home/opam/opam-repository
# path                 ~/.opam/5.2/.opam-switch/build/melange.3.0.0-51
# command              ~/.opam/5.2/bin/dune build -p melange -j 1 @install
# exit-code            1
# env-file             ~/.opam/log/melange-20-0841f9.env
# output-file          ~/.opam/log/melange-20-0841f9.out
### output ###
# (cd _build/default && /home/opam/.opam/5.2/bin/ocamlc.opt -w -9 -g -bin-annot -I vendor/melange-compiler-libs/lib/.melange_compiler_libs.objs/byte -I /home/opam/.opam/5.2/lib/menhirLib -I /home/opam/.opam/5.2/lib/ocaml/compiler-libs -I vendor/melange-compiler-libs/wrapper/.melange_wrapper.objs/byte -no-alias-deps -open Melange_compiler_libs__ -o vendor/melange-compiler-libs/lib/.melange_compiler_libs.objs/byte/melange_compiler_libs__Misc.cmi -c -intf vendor/melange-compiler-libs/lib/misc.mli)
# File "vendor/melange-compiler-libs/utils/misc.mli", line 469, characters 15-47:
# Error: Unbound type constructor "Melange_wrapper.Misc.Color.color"
# (cd _build/default && /home/opam/.opam/5.2/bin/ocamlc.opt -w -40 -w -69 -g -bin-annot -I jscomp/js_parser/.js_parser.objs/byte -no-alias-deps -open Js_parser -o jscomp/js_parser/.js_parser.objs/byte/js_parser__Flow_ast_mapper.cmo -c -impl jscomp/js_parser/flow_ast_mapper.ml)
# File "jscomp/js_parser/flow_ast_mapper.ml", line 1906, characters 7-12:
# 1906 |     [@@alert deprecated "Use either function_expression or class_method"]
#               ^^^^^
# Warning 53 [misplaced-attribute]: the "alert" attribute cannot appear in this context
# (cd _build/default && /home/opam/.opam/5.2/bin/ocamlopt.opt -w -40 -w -69 -g -O3 -unbox-closures -I jscomp/js_parser/.js_parser.objs/byte -I jscomp/js_parser/.js_parser.objs/native -intf-suffix .ml -no-alias-deps -open Js_parser -o jscomp/js_parser/.js_parser.objs/native/js_parser__Flow_ast_mapper.cmx -c -impl jscomp/js_parser/flow_ast_mapper.ml)
# File "jscomp/js_parser/flow_ast_mapper.ml", line 1906, characters 7-12:
# 1906 |     [@@alert deprecated "Use either function_expression or class_method"]
#               ^^^^^
# Warning 53 [misplaced-attribute]: the "alert" attribute cannot appear in this context
# (cd _build/.sandbox/18ba18a7722dac8844b705e4c060f6d2/default && /home/opam/.opam/5.2/bin/menhir --lalr --explain --dump --require-aliases --strict --table -lg 1 -la 1 --unused-token COMMENT --unused-token DOCSTRING --unused-token EOL --unused-token GREATERRBRACKET --fixed-exception vendor/melange-compiler-libs/lib/parser.mly --base vendor/melange-compiler-libs/lib/parser --infer-read-reply vendor/melange-compiler-libs/lib/parser__mock.mli.inferred)
# Grammar has 208 nonterminal symbols, among which 15 start symbols.
# Grammar has 123 terminal symbols.
# Grammar has 859 productions.
# Built an LR(0) automaton with 1875 states.
# The grammar is not SLR(1) -- 140 states have a conflict.
# The construction mode is lalr.
# Built an LR(1) automaton with 1875 states.
# 1069 shift/reduce conflicts were silently solved.
anmonteiro commented 6 months ago

This is what I'm working on at the moment

kit-ty-kate commented 5 months ago

Could this be reopened? The build is still failing with:

File "_build/default/vendor/melange-compiler-libs/gen/optional_5_2_modules.txt", line 1, characters 0-15:
1 | value_rec_types
    ^^^^^^^^^^^^^^^
Error: Module Value_rec_types doesn't exist.
kit-ty-kate commented 5 months ago

Also, whenever it compiles, could you ping me so i can add it to https://github.com/kit-ty-kate/opam-alpha-repository in order to test more of the ecosystem?

anmonteiro commented 5 months ago

This was in fact fixed in #1074 but the vendored submodule and the build is still on 5.1 because there was no version of odoc or ocamlformat compatible with OCaml 5.2 when we worked on it.

I think now that both odoc and ocamlformat can be pinned to work on OCaml 5.2 we could move development in the main branch to 5.2 to support building it out of the box. @jchavarri what do you think?

jchavarri commented 5 months ago

Sounds good to me! I will test 5.2 (with melange and friends) in Ahrefs codebase next week.