Skip to content

Upgrade vendored OCaml to 5.5.0 and merlin to 5.8.1-505 - #44

Merged
andreypopp merged 7 commits into
mainfrom
upgrade-ocaml-550
Sep 15, 2026
Merged

andreypopp merged 7 commits into
mainfrom
upgrade-ocaml-550

Conversation

@andreypopp

Copy link
Copy Markdown
Member

Upgrades the vendored submodules so the mlx dialect gains OCaml 5.5 syntax (effect handlers, etc.):

  • ocaml: 5.1.0 → 5.5.0 (mlx parser re-vendored, JSX patches ported onto the 5.5 grammar/lexer, AST target bumped to Astlib.Ast_505)
  • merlin: v4.14-501 → v5.8.1-505 (reader re-vendored, JSX patches ported, parsers regenerated)
  • menhir dev pin 20201216 → 20230608 (version merlin 5.8.1 vendors as menhirLib)
  • ppxlib lower bound → 0.38.0 (first release with the 5.5 AST)

Verified locally on a 5.5.0 switch: dev + release builds green, full cram suite passes (batch and merlin paths).

Draft to collect CI matrix signal on 4.14 / 5.4 / 5.5 — the older legs are expected to fail; their failures scope the backward-compat work.

🤖 Generated with Claude Code

andreypopp and others added 7 commits September 15, 2026 14:55
- bump ocaml submodule 5.1.0 -> 5.5.0
- re-vendor parsing sources via copy_files promotion
- port JSX grammar/lexer patches onto the 5.5.0 parser.mly/lexer.mll
- target Astlib.Ast_505 (ppxlib >= 0.38 provides it)
- adapt jsx_helper/mlx_shim to the new Longident.t with located
  components, Format_doc-based Location.errorf/msg, Pprintast.Doc

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- bump merlin submodule v4.14-501 -> v5.8.1-505
- re-vendor merlin sources via copy_files promotion; drop files removed
  upstream (utils/misc, utils/sys, typing/rec_check)
- port JSX patches onto 505 parser_raw.mly/lexer_raw.mll
- regenerate parser_raw/parser_recover/parser_printer
- bump menhir dev pin 20201216 -> 20230608 (version merlin 5.8.1
  vendors as menhirLib); update root menhirLib copy to match
- target Astlib.Ast_505; reorder opens so merlin Config wins over
  astlib's in mlx_ocaml_parsing
- sync mconfig_dot stub with 505 config shape; adapt frontend to the
  new Parsetree.constant record and Format_doc-based error reports
- accept 5.5-style unquoted code spans in error-message test output

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- ppxlib lower bound 0.34 -> 0.38 (first release with Ast_505)
- constrain merlin-lib >= 5.8.1
- CI: add 5.5 to the compiler matrix; bump menhir install to 20230608
- Makefile: create-switch now uses 5.5.0

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
On 5.5 the solver can only pick 5.8.1-505 anyway; on older compilers
the build fails in the vendored sources regardless (they use the 5.5
stdlib), so the constraint only moved the failure, and it offers no
protection against future merlin-lib releases either.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The vendored 5.5 sources referenced host compiler-libs APIs that only
exist on a 5.5 host (where astlib aliases to compiler-libs). Shim them
locally so the package builds on 4.14-5.4 hosts too:

- vendor the compiler's format_doc.{ml,mli} (with a local
  utf_8_scalar_width fallback, stdlib >= 5.4) into mlx_shim
- Misc.Style, Misc.Utf8_lexeme, Pprintast.Doc.tyvar,
  Clflags.{keyword_edition,parse_keyword_edition} shims
- no-op Builtin_attributes (w53 bookkeeping is the consuming
  compiler's job, not the preprocessor's)
- shadow Ocaml_common.Longident with the astlib one: menhir --infer
  bakes host-canonical type paths into the generated parser on a 5.5
  host, and this makes that spelling portable

Verified: dev+release build and tests on 5.5; release build on 5.4 and
4.14 host switches, with correct mlx-pp output from the 4.14 binary.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- fix the reader's Conv bridge, still on the Ast_501/OCaml_501 path
  from before the upgrade: with 505-shaped memory that Obj.magic chain
  was a latent runtime bug even on 5.5 (the cram tests bypass Conv);
  now converts 505 -> host version via ppxlib migrations
- shim stdlib APIs the vendored merlin 505 sources use, as local
  modules in mlx_utils reached through the existing -open chain:
  Seq.delay (5.5), Pair (5.4), String.edit_distance (5.4),
  Format.utf_8_scalar_width (5.4), Map.S of_list/to_list/add_to_list
  (5.1), Sys.is_regular_file (5.1), Digest.BLAKE128 (5.2, MD5-backed;
  only the type is used and a reader never populates consistbl)
- stub Merlin_index_format (absent from merlin-lib 4.x): the kernel
  only flushes its cache, which a reader never populates

Verified: 5.5 dev+release+tests; release builds on 5.4 (merlin-lib
5.7.1-504) and 4.14 (merlin-lib 4.19-414) host switches; the merlin
reader driver produces correct JSX output on both.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The cram MERLIN sections print the vendored AST directly, so Mlx_conv —
the Obj.magic + ppxlib migration bridge the reader actually uses to
hand its parsetree to the host merlin — had no coverage; the stale
Ast_501 bridge fixed earlier segfaulted yet all tests were green.

- extract Conv from the frontend into an mlx_conv library
- mlx_merlin.exe -conv (and -intf) runs the parse through Mlx_conv and
  prints via the HOST merlin-lib Pprintast, so a shape mismatch
  segfaults or garbles the output (verified: swapping the bridge back
  to OCaml_501 makes these tests crash with SIGSEGV)
- cram cases cover constants (the representation that changed across
  AST versions: int, string, float, char), nested JSX, punned and
  optional props, patterns, and signature conversion

Also verified by hand on 5.4 and 4.14 host switches, where the bridge
performs real 505->504 / 505->414 migrations.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Sep 15, 2026
@andreypopp
andreypopp marked this pull request as ready for review September 15, 2026 15:37
@andreypopp
andreypopp merged commit c333e46 into main Sep 15, 2026
7 of 19 checks passed
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.

1 participant