Repository navigation
Reject unit arguments of @set, @set_index and @get_index externals - #9343
Conversation
Why:
A unit argument is left out of the JS code, so the compiler crashed
with an assertion failure when it built the property access without
its object, index or value (#9339). @get already rejected it.
Diagnostic added (unit argument of a property external):
Example:
type t
@set external setX: (t, unit) => unit = "x"
Before (diagnostic):
Fatal error: exception File "compiler/core/lam_compile_external_call.ml", line 448, characters 11-17: Assertion failed
After (diagnostic):
Ill defined attribute @set (unit argument is not allowed)
Review: Can such an external be useful? No. It would set or read a property with a part missing. Declaring one now fails even when it is never called; before, only a call crashed.
Fixes #9339
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gHt1hL7PvCPo3r2viL
Signed-off-by: Christoph Knittel <ck@cca.io>
Changelog🐛 Bug fix
Semantic Diff2 commits · Full page Reject unit arguments of
|
✅ Compiler benchmarksAllocated wordsIn total: 639,845,235 → 639,843,825 (±0.00%). Generated projects: 629,807,957 → 629,806,518 (±0.00%). None of the 265 benchmarks changed by 0.1% or more. InstructionsIn total: 9,210,476,312 → 9,210,476,023 (±0.00%). None of the 33 benchmarks changed by 0.1% or more. Output sizeIn total: 25,919,386 → 25,919,534 (±0.00%). None of the 13 benchmarks changed by 0.1% or more. Pull request 8bdca68 compared with base 91d74a0 in this run. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9343 +/- ##
==========================================
- Coverage 82.15% 82.15% -0.01%
==========================================
Files 456 456
Lines 65658 65664 +6
==========================================
+ Hits 53942 53946 +4
- Misses 11716 11718 +2
🚀 New features to boost your workflow:
|
|
@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: 1ce26e02f4
ℹ️ 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:
When every argument is an @as constant, a unit parameter is added
after the arguments so the external stays callable. The new unit
check also saw that parameter, so it rejected valid externals such as
@get external readX: @as(json`{"x":1}`) _ => int = "x". The checks now
look at the declared arguments only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gHt1hL7PvCPo3r2viL
Signed-off-by: Christoph Knittel <ck@cca.io>
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! 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". |
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9343 |
Fixes #9339.
A
unitargument of an external is left out of the JS code. For@set,@set_indexand@get_indexthat leaves the property access without its object, index or value, and the compiler crashed withAssertion failed.@getalready rejected aunitargument.Now all four reject it when the external is declared:
This covers a
unitin any position, such as@set external setX: (unit, int) => unit.An external like this that is declared but never called compiled before and is now an error. It could not be called without crashing, so I don't expect real code to have one.
Tests: new fixtures
set_unit_arg.res,set_index_unit_arg.resandget_index_unit_arg.resintests/build_tests/super_errors.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gHt1hL7PvCPo3r2viL