Skip to content

Make Lambda invariant checking explicit - #8534

Merged
cristianoc merged 2 commits into
masterfrom
lam-check-command-line
Aug 9, 2026
Merged

Make Lambda invariant checking explicit#8534
cristianoc merged 2 commits into
masterfrom
lam-check-command-line

Conversation

@cristianoc

Copy link
Copy Markdown
Collaborator

Summary

  • add a runtime -check-lam compiler option
  • enable Lambda invariant checking across the main compiler test project
  • make -bs-diagnose imply Lambda checking
  • remove the legacy RELEASE CPPO distinction

Why

There is no user-visible debug versus release compiler behavior. Lambda checking was compiled into some native builds and omitted from release builds, which made coverage and regression detection depend on how the compiler was built. This makes checking explicit and keeps dev/release/static compilers functionally identical; Dune profiles now differ only for native optimization and browser selection.

The dump calls are explicitly owned by -bs-diagnose. Browser-specific dump stubs were removed after verifying js_of_ocaml eliminates the unreachable diagnose path without changing the raw playground bundle size.

Validation

  • make test
  • native dev and release compiler builds
  • native and release -check-lam smoke compilations
  • browser compiler build and bundle-size comparison
  • make checkformat

Stack

This is PR 1 of 2. The follow-up IR diagnostics cleanup targets this branch.

Replace the compile-time RELEASE distinction with a -check-lam runtime option. This keeps dev, release, and static compilers functionally identical while leaving Dune profiles responsible only for native optimization and browser selection.

Enable the option for the main compiler test project so Lambda invariants are exercised across ordinary local and CI test compilations and appear in coverage. Include the pass name in failures to make regressions actionable.

Keep -bs-diagnose as the umbrella diagnostic mode: it enables Lambda checks and owns all Lambda and JavaScript dump calls. Gating dumps at their call sites makes that relationship explicit and avoids duplicated configuration checks inside the dump implementations.

Remove the dump-specific BROWSER conditionals because the browser API cannot activate diagnose and js_of_ocaml eliminates the unreachable dump paths. A measured playground build had identical raw size, so retaining compile-time stubs added complexity without reducing the bundle.

Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
@cristianoc
cristianoc marked this pull request as ready for review August 9, 2026 09:07
@cristianoc
cristianoc requested a review from cknitt August 9, 2026 09:07
@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 74.59%. Comparing base (8b0477e) to head (afa22e6).

Files with missing lines Patch % Lines
compiler/core/lam_check.ml 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8534      +/-   ##
==========================================
- Coverage   74.59%   74.59%   -0.01%     
==========================================
  Files         458      458              
  Lines       62302    62303       +1     
==========================================
- Hits        46477    46476       -1     
- Misses      15825    15827       +2     
Files with missing lines Coverage Δ
compiler/bsc/rescript_compiler_main.ml 71.63% <100.00%> (+0.13%) ⬆️
compiler/common/js_config.ml 66.66% <ø> (ø)
compiler/core/lam_check.ml 95.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Aug 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8534

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8534

@rescript/darwin-x64

npm i https://pkg.pr.new/@rescript/darwin-x64@8534

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8534

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8534

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8534

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8534

commit: afa22e6

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

@cknitt

cknitt commented Aug 9, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: afa22e6937

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cknitt cknitt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to get rid of that RELEASE flag! 👍

@cristianoc
cristianoc merged commit c478363 into master Aug 9, 2026
29 checks passed
@cristianoc
cristianoc deleted the lam-check-command-line branch August 9, 2026 11:50
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.

2 participants