Repository navigation
Keep @directive on @this functions - #9262
Conversation
Changelog🐛 Bug fix
Semantic Diff2 commits · Full page Keep
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9262 +/- ##
=======================================
Coverage 81.94% 81.95%
=======================================
Files 456 456
Lines 65575 65616 +41
=======================================
+ Hits 53737 53777 +40
- Misses 11838 11839 +1
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac091eec07
ℹ️ 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".
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9262 |
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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:
The @this rewrite left @directive on the unsafe_to_method call
instead of the function, and the Pjs_fn_method path built the JS
function without a directive, so it was dropped without a report.
The PPX now moves @directive onto the inner function, E.method_
takes it, and the printer puts it before `let self = this`, since a
directive must be the first statement of the body.
JS modified (@this function with a directive):
Example:
let plain = @this @directive("'use cache'") (self, x) => self + x
Before (js):
function plain(x) {
let self = this ;
return self + x | 0;
}
After (js):
function plain(x) {
'use cache';
let self = this ;
return self + x | 0;
}
Fixes #9197
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gJuq6rWZULJVY3ATmY
Signed-off-by: Christoph Knittel <ck@cca.io>
The space was left over from when the printer spelled out `let self =` by hand; no other statement puts a space before its semicolon. JS modified (@this function): Example: let even = @this (o, x) => x + o Before (js): let o = this ; After (js): let o = this; Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kbf3gJuq6rWZULJVY3ATmY Signed-off-by: Christoph Knittel <ck@cca.io>
ac091ee to
feffddb
Compare
Changelog🐛 Bug fix
Semantic Diff2 commits · Full page Keep
|
✅ Compiler benchmarksAllocated wordsIn total: 682,341,187 → 682,359,517 (±0.00%). Generated projects: 923,206,992 → 923,212,416 (±0.00%). None of the 265 benchmarks changed by 0.1% or more. InstructionsIn total: 9,666,073,316 → 9,666,622,469 (+0.01%). None of the 33 benchmarks changed by 0.1% or more. Output sizeIn total: 25,812,251 → 25,812,418 (±0.00%). None of the 13 benchmarks changed by 0.1% or more. Pull request feffddb compared with base 32116b5 in this run. |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9262 |
cristianoc
left a comment
There was a problem hiding this comment.
Dot, Cristiano's assistant, reviewing at his request.
Traced @directive through the PPX-generated inner function, async transformation, Lambda/Pjs_fn_method, and JS method printing. It is emitted once before the this binding. Plain, async and unused-self snapshots cover the affected paths. No blocking findings; exact-head CI is green. I did not rerun compiler/tests locally.
Fixes #9197.
@thisfunctions dropped their@directive. There were two causes:bs_builtin_ppxleft the attribute on theunsafe_to_methodcall instead of the function, which is where translcore reads it. The PPX now moves@directiveonto the inner function.Pjs_fn_methodignoreddirective, andE.method_had no parameter for it.lam_compilenow passes it through.A directive has to be the first statement of the body, so
Js_dumpprints it beforelet self = this. This also works for async functions and whenselfis unused.New test:
tests/tests/src/this_directive.res, a JS snapshot covering the plain, async and unused-selfcases.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gJuq6rWZULJVY3ATmY