Repository navigation
Check @inline constants in signatures and their payloads - #9483
Conversation
Changelog🐛 Bug fix
Semantic Diff1 commit · Full page Check
|
|
@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: b8bdbe8467
ℹ️ 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".
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## remove-cross-module-opt #9483 +/- ##
========================================================
Coverage 82.46% 82.46%
========================================================
Files 466 466
Lines 66029 66070 +41
========================================================
+ Hits 54448 54486 +38
- Misses 11581 11584 +3
🚀 New features to boost your workflow:
|
✅ Compiler benchmarksAllocated wordsIn total: 674,610,681 → 674,608,294 (±0.00%). Generated projects: 630,566,002 → 630,566,091 (±0.00%).
(inputs changed): this pull request changes runtime or Belt sources, so these benchmarks compile different code than on the base, and their changes don't count as regressions. InstructionsIn total: 9,225,535,250 → 9,225,173,296 (±0.00%). None of the 33 benchmarks changed by 0.1% or more. Output sizeIn total: 27,350,702 → 27,351,980 (±0.00%). None of the 13 benchmarks changed by 0.1% or more. Pull request 2bb598f compared with base 4e9a23b in this run. |
b8bdbe8 to
c5e8794
Compare
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
c5e8794 to
c085466
Compare
c085466 to
a173165
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 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". |
a173165 to
c5bf043
Compare
c5bf043 to
2aca9bb
Compare
45949b3 to
705d4e3
Compare
705d4e3 to
1b603ff
Compare
Why:
A signature's `@inline(constant)` declaration was never checked against
its type, so `@inline("x") let x: int` was accepted and `M.x + 1`
compiled to `"x" + 1 | 0` until some implementation was matched against
it (#9468). An `@inline` without a constant in a signature did nothing
and said nothing; `Stdlib_Int.resi` had two of them. And in a structure,
any payload on a constant was ignored: `@inline(never) let y = 5` was
inlined, and `@inline(3) let x = 4` was the constant 4 without a word.
A payload that repeats the value, as packages such as rescript-nodejs
write it, stays a constant. This is PR 6 of the plan in #8733 (problem 2.11).
Typing modified (a signature's @inline constant):
Before (mapping): Typedecl.transl_value_decl
any declared type ↦ accepted
After (mapping): Typedecl.check_signature_inline_const
the literal's type, or an alias of it, private or not ↦ accepted
an abstract type ↦ accepted
another built-in type, a type variable, a concrete type ↦ error
Diagnostic added (signature constant with the wrong type):
Example:
module type S = {
@inline("x") let x: int
}
Before (diagnostic): none
After (diagnostic):
This @inline constant has type string, but it is declared with type int.
Diagnostic added (signature value without a constant):
Example:
module type S = {
@inline let r: int
}
Before (diagnostic): none
After (diagnostic):
Warning number 47
illegal payload for attribute @inline.
In a signature, it must be a string, int, float, bool or bigint literal, such as @inline(3)
Diagnostic added (payload on a constant):
Example:
@inline(3) let x = 4
@inline(never) let y = 5
@inline("ascii") let ascii = "ascii"
Before (diagnostic): none; all three are inlined constants
After (diagnostic): x and ascii stay constants, y is an ordinary value
Warning number 47
illegal payload for attribute @inline.
It differs from the value, which is used instead
Warning number 53
the @inline attribute cannot appear in this context
Review: Why may an abstract type hold a constant? `type t` with
`@inline(1) let one: t` hides the representation, which an implementation
with `type t = int` provides; matching it against the signature checks
the constant.
Review: Does the runtime change? No. `Stdlib_Int.resi` had two `@inline`
values without a constant, which did nothing and now warn; they are
plain values again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gJwNt3jmNq5d8xKA9D
Signed-off-by: Christoph Knittel <ck@cca.io>
1b603ff to
2bb598f
Compare
Diagnostics for
@inlineconstants. This is PR 6 of the plan in #8733 (problem 2.11), and it fixes #9468.Signature constants are checked against their type (#9468).
@inline("x") let x: intwas accepted, and code using the signature compiledM.x + 1to"x" + 1 | 0. The declared type may be:type t = intprovides.Another built-in type, a type variable, or a concrete type such as a variant is now an error: "This @inline constant has type string, but it is declared with type int."
An
@inlinein a signature without a constant (@inline let x: int) did nothing. It now gets warning 47.Stdlib_Int.resihad two, which are plain values again; the runtime's JavaScript doesn't change.Payloads on constants in a structure:
@inline(never)leaves an ordinary value, as on a function, with warning 53.alwaysgets warning 47 and leaves an ordinary value.@inline("ascii") let ascii = "ascii".@inline(3) let x = 4) stays a constant and gets warning 47.New tests:
tests/tests/src/inline_const_signature.res: the accepted declared types, and rescript-nodejs's pattern;Part of stack #9486, after #9480.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gJwNt3jmNq5d8xKA9D