Skip to content

Share the load-path lookup, polyvariant label printing and ident tables - #8990

Merged
cknitt merged 1 commit into
masterfrom
drift-8976-dedup
Oct 23, 2026
Merged

cknitt merged 1 commit into
masterfrom
drift-8976-dedup

Conversation

@cknitt

@cknitt cknitt commented Oct 23, 2026

Copy link
Copy Markdown
Member

Fixes #8976.

This removes the three duplicated pieces of logic the issue lists:

  • Load-path lookup. Misc.find_map_in_path_uncap path name f is now the only implementation of "the name as written, then uncapitalized, in each directory". Misc.find_in_path_uncap, the new Misc.find_in_path_uncap_opt (used by Config_util.find_opt, replacing its private copy) and Bs_cmi_load.load_cmi all go through it. Bs_cmi_load passes a function that opens and parses each candidate, so it keeps its single-open behaviour on case-insensitive file systems. The existing ounit_find_in_path_tests already check the lookup order through all three callers.
  • Identifier classifier in editor analysis. Utils.print_maybe_exotic_ident, a copy of Res_printer.classify_ident_content, is removed. Its only caller, the polyvariant completion in type_utils.ml, now uses Res_printer.print_poly_var_ident. That fixes the two places where the copies had diverged: the label 644 is now completed as #644 instead of #"644", and the empty label as #"" instead of a bare #.
  • Hash_set_ident. lam_check.ml and lam_dce.ml use Hash_ident (only create, mem and add), and the duplicate module is deleted.

Tests

exoticPolyvariant in tests/analysis_tests/tests/src/CompletionExpressions.res gains #644 and #"". It is extended on its existing line, so later test positions don't move, and the completion snapshot shows both labels.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xk6AeCYpCK4SZRtHYKHGoe

Why:
    The same logic was kept in several copies that had to change together.
    Misc.find_map_in_path_uncap is now the one "name as written, then
    uncapitalized" lookup, used by Misc.find_in_path_uncap, Config_util
    and Bs_cmi_load (#8925 had changed all three). Editor completion prints
    polyvariant labels with Res_printer.print_poly_var_ident instead of a
    copy of the printer's classifier, which had drifted. Lam_check and
    Lam_dce use Hash_ident, which Hash_set_ident duplicated since #8787.

Format modified (completion label of a polymorphic variant):
Example:
    type t = [#644 | #""]
    let f = (e: t) => ignore(e)
    // f()
    //   ^com
Before (text):
    #"644"
    #
After (text):
    #644
    #""

Signed-off-by: Christoph Knittel <ck@cca.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xk6AeCYpCK4SZRtHYKHGoe
@github-actions

Copy link
Copy Markdown

Semantic Diff

1 commit · Full page

Share the load-path lookup, polyvariant label printing and ident tables

bb32126 · Christoph Knittel with Claude Opus 5.5 · Oct 23, 2026

Why

The same logic was kept in several copies that had to change together. Misc.find_map_in_path_uncap is now the one "name as written, then uncapitalized" lookup, used by Misc.find_in_path_uncap, Config_util and Bs_cmi_load (#8925 had changed all three). Editor completion prints polyvariant labels with Res_printer.print_poly_var_ident instead of a copy of the printer's classifier, which had drifted. Lam_check and Lam_dce use Hash_ident, which Hash_set_ident duplicated since #8787.

Format modified (completion label of a polymorphic variant)

type t = [#644 | #""]
let f = (e: t) => ignore(e)
// f()
//   ^com

text

-#"644"
-#
+#644
+#""

@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.08108% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.23%. Comparing base (9e2f371) to head (bb32126).

Files with missing lines Patch % Lines
compiler/core/bs_cmi_load.ml 72.72% 3 Missing ⚠️
compiler/core/lam_check.ml 50.00% 2 Missing ⚠️
compiler/core/lam_dce.ml 75.00% 1 Missing ⚠️
compiler/ext/misc.ml 93.75% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8990   +/-   ##
=======================================
  Coverage   81.22%   81.23%           
=======================================
  Files         457      456    -1     
  Lines       63862    63834   -28     
=======================================
- Hits        51875    51854   -21     
+ Misses      11987    11980    -7     
Files with missing lines Coverage Δ
analysis/src/type_utils.ml 66.13% <100.00%> (ø)
analysis/src/utils.ml 48.42% <ø> (-1.29%) ⬇️
compiler/core/config_util.ml 100.00% <100.00%> (+6.25%) ⬆️
compiler/core/lam_dce.ml 92.10% <75.00%> (-0.21%) ⬇️
compiler/ext/misc.ml 82.39% <93.75%> (+0.17%) ⬆️
compiler/core/lam_check.ml 93.13% <50.00%> (ø)
compiler/core/bs_cmi_load.ml 72.72% <72.72%> (-5.06%) ⬇️
🚀 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 Oct 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@8990

@rescript/darwin-arm64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: bb32126

@github-actions

Copy link
Copy Markdown

@cknitt
cknitt marked this pull request as ready for review October 23, 2026 09:25
@cknitt

cknitt commented Oct 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-23T09:25:32.264172Z bb32126 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cknitt
cknitt requested a review from cristianoc October 23, 2026 09:27
@cknitt
cknitt enabled auto-merge (squash) October 23, 2026 09:27
@cknitt
cknitt merged commit 0894c67 into master Oct 23, 2026
26 checks passed
@cknitt
cknitt deleted the drift-8976-dedup branch October 23, 2026 10:51
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.

Logic maintained in several copies: load-path lookup, identifier classifier, ident hash sets

2 participants