Skip to content

Tell interface files from implementation files again in editor analysis - #9337

Merged
cknitt merged 1 commit into
masterfrom
fix-uri-is-interface
Nov 19, 2026
Merged

cknitt merged 1 commit into
masterfrom
fix-uri-is-interface

Conversation

@cknitt

@cknitt cknitt commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Since #8436, Uri.is_interface passes its arguments to Filename.check_suffix in the wrong order, so it always returns false. Editor analysis then pairs a .resi declaration with itself instead of with its .res side: Find References lists the .resi location twice and misses the .res one, Rename edits the .resi twice and leaves the .res unchanged, and go to definition from a .resi declaration stays in the interface.

The fix tests the URI's path with String.ends_with ~suffix:Literals.suffix_resi, whose labeled argument can't be swapped. Shared_types.get_cmt_path, which had its own copy of the test, now calls Uri.is_interface.

Tests: the existing snapshots Cross, DefinitionWithInterface.resi, Jsx2, References, ReferencesWithInterface.resi and RenameWithInterface.resi change. Each duplicate .resi entry becomes the .res entry, and definitions from a .resi reach the implementation again.

#9332 is stacked on this PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kbf3gGbYDy2DBe5YmGdHTL

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Changelog

🐛 Bug fix

  • Find References and Rename no longer list a value of a .resi file twice and miss its .res side, and go to definition from a .resi declaration opens the implementation again.

Semantic Diff

1 commit · Full page

✏️ Tell interface files from implementation files again in editor analysis

8aa74ec · cknitt + Claude · Nov 19, 2026, 17:01 UTC · edited

Why

Since #8436, Uri.is_interface passes its arguments to Filename.check_suffix in the wrong order, so it always returns false. Editor analysis then pairs a .resi declaration with itself instead of with its .res side: references list the .resi location twice and miss the .res one, rename edits the .resi twice and leaves the .res unchanged, and go to definition from a .resi declaration stays in the interface.

References modified (a value with an interface)

// ReferencesWithInterface.res
let x = 2
// ReferencesWithInterface.resi
let x: int

text · references of x from the .resi

 …
 ReferencesWithInterface.resi  0:4
-ReferencesWithInterface.resi  0:4
+ReferencesWithInterface.res   0:4

Definition modified (from a declaration in a .resi)

text · tests/analysis_tests/tests/src/DefinitionWithInterface.resi

-DefinitionWithInterface.resi
+DefinitionWithInterface.res

Review

  • Why String.ends_with ~suffix:Literals.suffix_resi? Its labeled argument cannot be swapped the way the positional arguments of Filename.check_suffix were, and the compiler's .resi constant says what is meant. It tests the URI's path (Lsp.Uri.to_path), which ignores query and fragment, instead of the whole encoded URI. Shared_types.get_cmt_path, which picks the .cmti for an interface URI, had its own copy of the test and now calls Uri.is_interface.
  • Which snapshots change? Cross, DefinitionWithInterface.resi, Jsx2, References, ReferencesWithInterface.resi and RenameWithInterface.resi: each duplicate .resi entry becomes the .res entry, and definitions from a .resi reach the implementation, as they did before Use Yojson and lsp types for analysis JSON output #8436.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

✅ Compiler benchmarks

Allocated words

In total: 639,850,034 → 639,849,724 (±0.00%).

Generated projects: 629,813,421 → 629,814,170 (±0.00%).

None of the 265 benchmarks changed by 0.1% or more.

Instructions

In total: 9,210,476,629 → 9,210,476,629 (±0.00%).

None of the 33 benchmarks changed by 0.1% or more.

Output size

In total: 25,919,386 → 25,919,386 (±0.00%).

None of the 13 benchmarks changed by 0.1% or more.

Pull request 8aa74ec compared with base 91d74a0 in this run.

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.15%. Comparing base (0b2246c) to head (8aa74ec).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9337      +/-   ##
==========================================
+ Coverage   82.12%   82.15%   +0.02%     
==========================================
  Files         456      456              
  Lines       65661    65656       -5     
==========================================
+ Hits        53926    53939      +13     
+ Misses      11735    11717      -18     
Files with missing lines Coverage Δ
analysis/src/shared_types.ml 83.57% <100.00%> (-0.12%) ⬇️
analysis/src/uri.ml 88.88% <100.00%> (ø)

... and 31 files 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.

@cknitt
cknitt force-pushed the fix-uri-is-interface branch from 3829206 to 4a2062b Compare November 19, 2026 17:11
@pkg-pr-new

pkg-pr-new Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 8aa74ec

@github-actions

Copy link
Copy Markdown

@cknitt
cknitt force-pushed the fix-uri-is-interface branch 3 times, most recently from 0457ec2 to 0aa4953 Compare November 19, 2026 18:45
@cknitt

cknitt commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

@codex review

@cknitt
cknitt marked this pull request as ready for review November 19, 2026 18:46
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T02:08:31.512234Z c83f5af 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 0aa49531e2

ℹ️ 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".

Why:
    Since #8436, `Uri.is_interface` passes its arguments to
    `Filename.check_suffix` in the wrong order, so it always returns false.
    Editor analysis then pairs a `.resi` declaration with itself instead of
    with its `.res` side: references list the `.resi` location twice and
    miss the `.res` one, rename edits the `.resi` twice and leaves the
    `.res` unchanged, and go to definition from a `.resi` declaration stays
    in the interface.

References modified (a value with an interface):
Example:
    // ReferencesWithInterface.res
    let x = 2
    // ReferencesWithInterface.resi
    let x: int
Before (text): references of x from the .resi
    …
    ReferencesWithInterface.resi  0:4
    ReferencesWithInterface.resi  0:4
After (text): references of x from the .resi
    …
    ReferencesWithInterface.resi  0:4
    ReferencesWithInterface.res   0:4

Definition modified (from a declaration in a .resi):
Before (text): tests/analysis_tests/tests/src/DefinitionWithInterface.resi
    DefinitionWithInterface.resi
After (text): tests/analysis_tests/tests/src/DefinitionWithInterface.resi
    DefinitionWithInterface.res

Review: Why `String.ends_with ~suffix:Literals.suffix_resi`? Its
    labeled argument cannot be swapped the way the positional arguments of
    `Filename.check_suffix` were, and the compiler's `.resi` constant says
    what is meant. It tests the URI's path (`Lsp.Uri.to_path`), which
    ignores query and fragment, instead of the whole encoded URI.
    `Shared_types.get_cmt_path`, which picks the `.cmti` for an interface
    URI, had its own copy of the test and now calls `Uri.is_interface`.

Review: Which snapshots change? Cross, DefinitionWithInterface.resi,
    Jsx2, References, ReferencesWithInterface.resi and
    RenameWithInterface.resi: each duplicate `.resi` entry becomes the
    `.res` entry, and definitions from a `.resi` reach the implementation,
    as they did before #8436.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gGbYDy2DBe5YmGdHTL
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt force-pushed the fix-uri-is-interface branch from 0aa4953 to 8aa74ec Compare November 19, 2026 18:57
@cknitt
cknitt merged commit c83f5af into master Nov 19, 2026
22 checks passed
@cknitt
cknitt deleted the fix-uri-is-interface branch November 19, 2026 19:43
@cknitt

cknitt commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: c83f5afe49

ℹ️ 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".

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