Skip to content

Allow $ in identifiers - #8791

Merged
cknitt merged 7 commits into
fix-shadow-rename-collisionfrom
allow-dollar-identifiers
Oct 11, 2026
Merged

cknitt merged 7 commits into
fix-shadow-rename-collisionfrom
allow-dollar-identifiers

Conversation

@cknitt

@cknitt cknitt commented Oct 11, 2026

Copy link
Copy Markdown
Member

Allows $ anywhere in identifiers, as in JS (e.g. let count$ = signal(0), let $count = …, record fields, labels and polyvariant tags). Closes #8094.

This is #8095 rebased onto #8778, which makes the JS printer's renaming of shadowed variables safe for identifiers containing $. The $-escaping problem that held up #8095 was that bug, and it already affected escaped identifiers like \"x$1" on master.

Compared to #8095:

  • The printer prints $ identifiers without escapes, so existing \"...$..." names in the repo are reformatted.
  • Editor completion inserts $ polyvariant tags without quotes (#count$, not #"count$").
  • The changes to the legacy j string interpolation and Primitive_curry.res are dropped; both have been removed from master.

New tests:

  • Syntax: parsing/other/dollarIdent.res and printer/identifiers/dollarIdent.res; badCharacter.res now parses let $ = 1.
  • tests/tests/src/dollar_ident_js_test.res pins the JS output for $ values, fields and labels.
  • dollar_escape_test.res checks that a shadowing $ doesn't capture a $$1 parameter.
  • Analysis: #dollar$ and #count$ tags in the completion and exhaustive-switch tests.

🤖 Generated with Claude Code

@cknitt
cknitt added this pull request to stack #8792 October 11, 2026 05:31
@cknitt cknitt mentioned this pull request Oct 11, 2026
@cknitt
cknitt marked this pull request as ready for review October 11, 2026 05:49
@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-11T07:07:01.762039Z 14a034b 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.

@codecov

codecov Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.59%. Comparing base (9b26cdd) to head (83ce320).

Files with missing lines Patch % Lines
analysis/src/utils.ml 0.00% 2 Missing ⚠️
Additional details and impacted files
@@                       Coverage Diff                       @@
##           fix-shadow-rename-collision    #8791      +/-   ##
===============================================================
- Coverage                        80.59%   80.59%   -0.01%     
===============================================================
  Files                              453      453              
  Lines                            62028    62029       +1     
===============================================================
- Hits                             49991    49990       -1     
- Misses                           12037    12039       +2     
Files with missing lines Coverage Δ
compiler/syntax/src/res_printer.ml 93.52% <100.00%> (ø)
compiler/syntax/src/res_scanner.ml 91.10% <100.00%> (+0.01%) ⬆️
analysis/src/utils.ml 50.87% <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.

@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: 6a5bf292b1

ℹ️ 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 compiler/syntax/src/res_printer.ml Resolved
@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@8791

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 83ce320

@cknitt

cknitt commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 14a034bba5

ℹ️ 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 requested a review from cristianoc October 11, 2026 07:09
cknitt and others added 7 commits October 11, 2026 11:51
Signed-off-by: Christoph Knittel <ck@cca.io>
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>
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>
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>
@cknitt
cknitt force-pushed the allow-dollar-identifiers branch from 14a034b to 83ce320 Compare October 11, 2026 11:54
@cknitt
cknitt merged commit a144477 into master Oct 11, 2026
24 checks passed
@cknitt
cknitt deleted the allow-dollar-identifiers branch October 11, 2026 15:12
aspeddro pushed a commit to aspeddro/rescript-compiler that referenced this pull request Oct 31, 2026
* Allow $ in identifiers

Signed-off-by: Christoph Knittel <ck@cca.io>

* Test $ identifier shadowing

Signed-off-by: Christoph Knittel <ck@cca.io>

* Complete $ polyvariant tags without quotes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>

* Format $ identifiers without escapes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>

* CHANGELOG

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>

* Scan identifiers starting with _$

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>

* Format

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>

---------

Signed-off-by: Christoph Knittel <ck@cca.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Pedro Castro <aspeddro@gmail.com>
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.

Allow $ in identifiers

2 participants