Skip to content

Fix GenType path resolution for Windows short paths and POSIX symlinks - #8639

Merged
fhammerschmidt merged 13 commits into
masterfrom
fix/gentype-windows-paths
Oct 15, 2026
Merged

fhammerschmidt merged 13 commits into
masterfrom
fix/gentype-windows-paths

Conversation

@fhammerschmidt

@fhammerschmidt fhammerschmidt commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Summary

GenType could hang on Windows when the project root used an 8.3 short path while compiler source locations used its expanded form. The unmatched absolute path reached a drive root whose parent never changed. On POSIX, building a symlinked project from another working directory could also fail to write GenType output.

Pass the already canonical package path as -bs-project-root during builds, matching the parser's working directory without canonicalizing again for each file. Preserve the caller's project path in compiler-args, since editor incremental type checking compiles absolute source paths through that spelling. Stop resolver traversal whenever a path's parent is stable.

Validation

  • A Windows integration test obtains an explicit 8.3 alias, skipping when short names are unavailable. A POSIX regression builds a symlinked project from another working directory. Both exercise cross-directory GenType module resolution and assert the exact generated import path.
  • Both cases also invoke compiler-args and compile an absolute incremental source with the returned flags, as the editor does. The POSIX editor regression passes with this change and fails on the previous PR head.
  • Added direct OCaml coverage for relative paths and Windows drive-root traversal. The test runner now runs the GenType unit cases on Windows, where the rest of the OUnit suite remains skipped.
  • Full compiler tests: 268 passing unit cases, 591 runtime cases, 41 build fixtures, and 744 docstring cases. The Windows-specific unit case is skipped locally and runs in Windows CI.
  • Both GenType integration suites and TypeScript checks pass.
  • Rust unit tests and Clippy with warnings denied pass.
  • Repository formatting and changelog validation pass.

@fhammerschmidt
fhammerschmidt marked this pull request as ready for review September 10, 2026 09:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

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 ✅ Completed 2026-10-09T13:26:28.105380Z a5a255d 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af184c16b5

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

Comment thread rewatch/src/config.rs Outdated
@codecov

codecov Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.50%. Comparing base (8d51b9c) to head (23fe47e).
⚠️ Report is 26 commits behind head on master.

Files with missing lines Patch % Lines
tests/ounit_tests/ounit_gentype_tests.ml 58.33% 5 Missing ⚠️
compiler/gentype/module_resolver.ml 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8639      +/-   ##
==========================================
+ Coverage   80.40%   80.50%   +0.09%     
==========================================
  Files         447      447              
  Lines       60990    61071      +81     
==========================================
+ Hits        49042    49167     +125     
+ Misses      11948    11904      -44     
Files with missing lines Coverage Δ
compiler/gentype/module_resolver.ml 81.60% <66.66%> (-1.35%) ⬇️
tests/ounit_tests/ounit_gentype_tests.ml 82.75% <58.33%> (-17.25%) ⬇️

... and 37 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.

@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 23fe47e

@fhammerschmidt
fhammerschmidt added this pull request to stack #8642 September 10, 2026 10:59
@fhammerschmidt
fhammerschmidt force-pushed the fix/gentype-windows-paths branch from 0d7a3c2 to 9ac4780 Compare September 11, 2026 13:49
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
@fhammerschmidt
fhammerschmidt force-pushed the fix/gentype-windows-paths branch 2 times, most recently from 0175386 to b81ba05 Compare September 11, 2026 15:38
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
@fhammerschmidt
fhammerschmidt force-pushed the fix/gentype-windows-paths branch from b81ba05 to 3102f42 Compare September 11, 2026 16:41
@github-actions

Copy link
Copy Markdown

@fhammerschmidt

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 3102f42d77

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

@fhammerschmidt
fhammerschmidt removed this pull request from stack #8642 September 11, 2026 20:25
@fhammerschmidt
fhammerschmidt added this pull request to stack #8650 September 11, 2026 20:25
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
@fhammerschmidt
fhammerschmidt removed this pull request from stack #8650 October 9, 2026 13:07
@fhammerschmidt

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: a5a255da21

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

Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
@cknitt

cknitt commented Oct 13, 2026

Copy link
Copy Markdown
Member

🤖 This review was generated by Claude (Claude Code) on behalf of @cknitt.

Verdict: approve with nits. No correctness bugs found. Making -bs-project-root canonical (matching package.path) is the right fix, and the dirname path = path guard makes path_to_list always terminate.

  • Not Windows-only. The same root mismatch breaks rescript build <symlinked-dir> on POSIX. On master, building a symlinked project from another cwd fails with I/O error: /tmp/X-link//tmp/X/src-a/A.gen.tsx: No such file or directory; with this PR it produces from '../../src-a/A.gen'. Worth mentioning in the title/changelog.
  • Test gap: on Linux/macOS, rewatch/tests/gentype/project-root.mjs passes with or without the Rust change, because the kernel's getcwd already resolves symlinks (including macOS /var → /private/var). Suggestions:
    • Anchor the assertion: /\.\.\/\.\.\/src-a\/A\.gen/ would also match a wrong ../../../../src-a/A.gen. Assert on from '../../src-a/A.gen' instead.
    • Add a POSIX case that symlinks the project and runs rescript build <symlink> from a different cwd.
    • The path_to_list guard has no test of its own; reverting it keeps everything green. A small OCaml unit test would be cheap.
  • Minor:
    • The Windows test fails (notEqual) instead of skipping when 8.3 short names are disabled on the volume.
    • On a hang, the spawnSync 30s timeout kills cmd.exe but can leave rescript.exe/bsc.exe running, which could trip suite.sh's stale-process check.
    • In rescript compiler-args, -bs-project-root is now canonical while the parser args stay relative. On Windows, a consumer that gives bsc a non-canonical (e.g. 8.3) cwd could now mismatch. Probably rare; worth checking how the editor extension spawns bsc.
    • get_project_root_args canonicalizes once per compiled file; it could be computed once.

Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
@fhammerschmidt fhammerschmidt changed the title Fix GenType path resolution on Windows Fix GenType path resolution for Windows short paths and POSIX symlinks Oct 13, 2026
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>

Copy link
Copy Markdown
Member Author

23fe47e59 addresses the remaining substantive points. Builds now pass the already canonical package path as -bs-project-root, avoiding canonicalization per file. compiler-args preserves the caller’s root spelling: I reproduced editor incremental compilation failing through a POSIX symlink with the previous change, and the added regression passes now and fails on the previous PR head.

The title/changelog cover POSIX symlinks, the integration test builds through a symlink from another working directory and checks the exact generated import, and Windows skips the short-path case when 8.3 names are unavailable. Added direct drive-root traversal tests and enabled the GenType unit cases on Windows; the Windows compiler test step has passed.

Windows timeout process-tree cleanup remains deferred as optional test robustness work. Local compiler, GenType, Rust, formatting, and changelog checks pass. DCO now passes; the full CI and coverage runs are still in progress.

@fhammerschmidt
fhammerschmidt merged commit bfbc9ee into master Oct 15, 2026
26 checks passed
@fhammerschmidt
fhammerschmidt deleted the fix/gentype-windows-paths branch October 15, 2026 11:33
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.

3 participants