Skip to content

Keep _-prefixed exotic identifiers escaped, reject \"_\" - #8795

Merged
cknitt merged 3 commits into
masterfrom
fix-underscore-exotic-idents
Oct 12, 2026
Merged

cknitt merged 3 commits into
masterfrom
fix-underscore-exotic-idents

Conversation

@cknitt

@cknitt cknitt commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

The printer printed escaped identifiers that start with _ bare even when the scanner can't read them back. The scanner treats _ as an identifier only when a letter, digit, _ or $ follows, so these became syntax errors after formatting:

let \"_'" = 2         // printed as `let _' = 2`
let f = (~\"_'") => 1 // printed as `(~_') => 1`
type r = {\"_'": int}  // printed as `{_': int}`
let b = #"_"           // printed as `#_`

classify_ident_content now mirrors the scanner, and editor completion uses the same rule for polyvariant tags.

Breaking: \"_" is now rejected as a quoted identifier ("_ can't be used as a quoted identifier."). It couldn't be told apart from the _ wildcard and the placeholder of underscore apply sugar: f(\"_") was parsed as f(_), i.e. __x => f(__x), and let \"_" = 1 was printed as let _ = 1. Nothing in the repo used it; a JS name _ is still reachable through @as("_") or an external's string name, and the tag #"_" stays valid.

New tests: printer/expr/underscoreExoticIdent.res, parsing/errors/scanner/quotedUnderscore.res, and a #"_" tag in the CompletionExpressions analysis test.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NrGqwcpQ2sF3RiHA48TxmU

@codecov

codecov Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.38%. Comparing base (904027b) to head (b8e5d07).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
analysis/src/utils.ml 0.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8795   +/-   ##
=======================================
  Coverage   80.38%   80.38%           
=======================================
  Files         447      447           
  Lines       60979    60991   +12     
=======================================
+ Hits        49016    49026   +10     
- Misses      11963    11965    +2     
Files with missing lines Coverage Δ
compiler/syntax/src/res_printer.ml 93.53% <100.00%> (+0.01%) ⬆️
compiler/syntax/src/res_scanner.ml 91.16% <100.00%> (+0.06%) ⬆️
analysis/src/utils.ml 50.57% <0.00%> (-0.31%) ⬇️
🚀 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 commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-12T04:50:29.717077Z b8e5d07 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.

@pkg-pr-new

pkg-pr-new Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: b8e5d07

@github-actions

Copy link
Copy Markdown

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 933ffa5e26

ℹ️ 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 marked this pull request as ready for review October 11, 2026 12:34
@cknitt
cknitt requested a review from cristianoc October 11, 2026 12:34
cknitt and others added 3 commits October 12, 2026 04:41
Escape names like \"_'\" and \"_\" that the scanner would read as a wildcard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
It couldn't be told apart from the wildcard and the placeholder of
underscore apply sugar, e.g. f(\"_\") was parsed as f(_).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NrGqwcpQ2sF3RiHA48TxmU
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt force-pushed the fix-underscore-exotic-idents branch from 933ffa5 to b8e5d07 Compare October 12, 2026 04:46
@cknitt cknitt changed the title Keep _-prefixed exotic identifiers escaped when printing Keep _-prefixed exotic identifiers escaped, reject \"_\" Oct 12, 2026
@cknitt

cknitt commented Oct 12, 2026

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: b8e5d07c44

ℹ️ 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 enabled auto-merge (squash) October 12, 2026 04:53
@cknitt
cknitt merged commit bbac536 into master Oct 12, 2026
24 checks passed
@cknitt
cknitt deleted the fix-underscore-exotic-idents branch October 12, 2026 05:04
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