Repository navigation
Conversation
Calling a method read from an open JS object type, such as
`obj["getData"]("text/plain")` with `obj: {..}`, no longer reports warning
20 "this argument will not be used by the function". The method's type is a
fresh type variable, which the warning took as a sign that the function
never returns, but the call passes its arguments to the JS method. Calls
whose function is a fresh type variable for other reasons, such as
`failwith("x")(1)`, still warn.
Example (rescript):
@get external clipboardData: string => {..} = "clipboardData"
let text = clipboardData("event")["getData"]("text/plain")
Diagnostic (text):
Before: Warning number 20 on "text/plain":
this argument will not be used by the function.
After: no warning.
Area: typechecker tests
Output: unchanged
Formatting: unchanged
Formats: none
PPX: unchanged
Editor: unchanged
Tests: +tests/build_tests/super_errors/fixtures/unused_argument_object_method.res +tests/build_tests/super_errors/expected/unused_argument_object_method.res.expected
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kr4cjoUi2f5VpMvE6wT9bo
Signed-off-by: Christoph Knittel <ck@cca.io>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8921 +/- ##
==========================================
+ Coverage 81.03% 81.14% +0.10%
==========================================
Files 455 456 +1
Lines 63640 63758 +118
==========================================
+ Hits 51573 51735 +162
+ Misses 12067 12023 -44
🚀 New features to boost your workflow:
|
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-8921 |
|
@codex review |
Codex Review SummaryThis 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: a085ae910f
ℹ️ 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".
Calling an object field still reports warning 20 "this argument will not be
used by the function" unless the read added the field to an open object row.
The exemption for open JS object methods covered every object field read, so
calls of fields that cannot return, such as `failwith("boom")["m"](x)` or
`{"m": failwith("boom")}["m"](x)`, lost the warning. The read now records the
fresh variable it creates for a field added to an open row, and the
application skips the warning only when its callee is that variable.
Example (rescript):
@get external clipboardData: string => {..} = "clipboardData"
let text = clipboardData("event")["getData"]("text/plain")
let fromFailwith = () => failwith("boom")["m"](Console.log("b"))
Diagnostic (text):
Before: no warning on either call.
After: warning 20 on Console.log("b") only, as on master.
Review: Why a global slot rather than a typed-tree flag? The callee's read is
the last read typed before its application, and the slot is set on every
read and compared by physical equality with the callee's type, so it only
matches the callee's own read. A typed-tree field would change Texp_object_get
and the .cmt format for a warning.
Area: typechecker tests
Output: unchanged
Formatting: unchanged
Formats: none
PPX: unchanged
Editor: unchanged
Tests: ~tests/build_tests/super_errors/fixtures/unused_argument_object_method.res ~tests/build_tests/super_errors/expected/unused_argument_object_method.res.expected
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kr4cjoUi2f5VpMvE6wT9bo
Signed-off-by: Christoph Knittel <ck@cca.io>
Arguments that read object fields, from closed or open objects, in first or
last position or through a nested method call, keep the call of an open JS
object method free of warning 20. The exemption is decided before any
argument is typed, so their reads cannot replace the callee's.
Example (rescript):
let closedFirst = clipboardData("e")["m"](closed["x"], "a")
let nested = clipboardData("e")["m"](clipboardData("f")["n"]("y"))
Diagnostic (text):
no warning, before and after this commit.
Area: tests
Output: unchanged
Tests: ~tests/build_tests/super_errors/fixtures/unused_argument_object_method.res ~tests/build_tests/super_errors/expected/unused_argument_object_method.res.expected
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kr4cjoUi2f5VpMvE6wT9bo
Signed-off-by: Christoph Knittel <ck@cca.io>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0b9449a508
ℹ️ 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".
The fixture for warning 20 on object methods writes its never-returning
expressions as `throw(Failure(...))` instead of the deprecated `failwith`, so
its expected output holds only warning 20 once `failwith` reports warning 3.
It also covers an open object that is kept in a binding and whose method is
read before it is called: that call reports no warning 20 either.
Example (rescript):
let retained = clipboardData("e")
let first = retained["m"]
let second = retained["m"]("used")
Diagnostic (text):
no warning on `"used"`.
Review: Does the retained case need a record of every open-row field
variable? No: a binding keeps the object type at the binding's level, below
the level of the later call, so the call's fresh-variable check does not
apply and no warning is reported.
Area: tests
Output: unchanged
Tests: ~tests/build_tests/super_errors/fixtures/unused_argument_object_method.res ~tests/build_tests/super_errors/expected/unused_argument_object_method.res.expected
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kr4cjoUi2f5VpMvE6wT9bo
Signed-off-by: Christoph Knittel <ck@cca.io>
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
Calling a method of an open JS object type, e.g.
cd(e)["getData"]("text/plain")withcd: string => {..}, reported warning 20 "this argument will not be used by the function". The method's type is a fresh type variable, which the warning reads as "the function never returns", but the JS method does receive the argument. The warning is now skipped when the applied expression is an object property read (Texp_object_get); other fresh-variable cases such asfailwith("x")(1)still warn.Fixes #8159.
New super_errors fixture
unused_argument_object_method.rescovers both the object method call (no warning) and thefailwithcase (warning kept).🤖 Generated with Claude Code
https://claude.ai/code/session_01Kr4cjoUi2f5VpMvE6wT9bo