Repository navigation
Fix @warning reported several times and ignored in translation - #9491
Conversation
Changelog🐛 Bug fix
Semantic Diff1 commit · Full page ✏️ Fix
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## fix-printer-constraint-attributes #9491 +/- ##
=====================================================================
+ Coverage 82.50% 82.51% +0.01%
=====================================================================
Files 467 467
Lines 66127 66133 +6
=====================================================================
+ Hits 54555 54567 +12
+ Misses 11572 11566 -6
🚀 New features to boost your workflow:
|
✅ Compiler benchmarksAllocated wordsIn total: 655,167,683 → 655,193,894 (±0.00%). Generated projects: 627,289,701 → 627,355,390 (+0.01%).
InstructionsIn total: 9,128,461,676 → 9,129,986,150 (+0.02%).
Output sizeIn total: 27,368,926 → 27,369,214 (±0.00%). None of the 13 benchmarks changed by 0.1% or more. Pull request d9aebad compared with base 64cd1e0 in this run. |
281f0bd to
31ae28c
Compare
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-9491 |
|
@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: 31ae28c61c
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a5815ff9f
ℹ️ 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".
8ebf4d5 to
64174bf
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! 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". |
64174bf to
dbe39ca
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". |
dbe39ca to
277442c
Compare
277442c to
f71f99a
Compare
Why:
Builtin_attributes.warning_attribute both applied a warning setting
and reported problems with it. The type checker enters a binding's
warning scope once for each of its passes, so a malformed payload
was reported up to six times. The ~ppwarning:false flag of the
repeated scopes only skipped @ppwarning. The frontend also applied
and reported the leading @@warning items, and left its warning state
in place for the type checker and translation.
Translation to Lambda reports some warnings itself, such as 102 for
a polymorphic comparison. It applied the warning attributes of let
bindings, expressions and module expressions again, but not those of
module bindings, recursive modules, includes, type constraints,
expression statements and floating @@warning items. So
`@warning("-102")` on a module did not silence 102 inside it, and in
a build `@@warning("+102")` never enabled it.
Builtin_attributes now has two kinds of scope. warning_scope applies and
reports, and only the type checker's first pass over a node uses it.
replay_warning_scope applies silently, for the type checker's repeated
passes, including the second pass over a recursive module, the frontend,
translation and Inline_not_stored. The ~ppwarning flag is gone.
The frontend runs the built-in PPX in a replay_warning_scope over the
leading floating attributes, so type checking starts from the command
line's warning state, in one-step compiles as in builds.
Translmod applies a floating attribute in a scope around the rest of its
structure. It translates the rest of a structure before the item itself,
so the scope ends before the items above the attribute are translated.
Module bindings, recursive modules, includes and expression statements
get a scope of their attributes, and the scope of a binding also covers
the checks of its @inline attribute. Translcore.transl_exp also applies
the attributes of type constraints, which a new
Typedtree.exp_warning_attributes collects in scope order, as typemod
already did for warning 113.
Diagnostic modified (malformed @warning payload):
Example:
@warning(3) let x = 1
Before (diagnostic):
Warning number 47 (reported 6 times)
illegal payload for attribute @warning.
A single string literal is expected
After (diagnostic):
Warning number 47 (reported once)
illegal payload for attribute @warning.
A single string literal is expected
Diagnostic modified (warning 102 in a module with @warning("-102")):
Example:
@warning("-102")
module M = {
let compares = [1] == [2]
}
Before (diagnostic):
Warning number 102
Polymorphic comparison introduced (maybe unsafe)
After (diagnostic): (nothing reported)
Fixes #9488
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gH9cXWp3xtBmfRV3Du
Signed-off-by: Christoph Knittel <ck@cca.io>
f71f99a to
d9aebad
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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". |
Fixes #9488. Stacked on #9498, a formatter fix that the new test fixture needs.
A malformed
@warningor@warnerrorpayload was reported up to six times, and some warning attributes had no effect on warnings reported during translation:The cause.
Builtin_attributes.warning_attributeboth applied a warning setting and reported problems with it. Several phases apply the same attributes:~ppwarning:falseflag of the repeated passes only skipped@ppwarning, so a malformed payload was reported on every pass.@@warningitems for the built-in PPX, and left its warning state in place for the later phases.letbindings, expressions and module expressions again, but not those of module bindings,module rec,include, type constraints, expression statements and floating@@warningitems. In a build,@@warning("+102")therefore never enabled 102.The fix.
Builtin_attributeshas two kinds of scope.warning_scopeapplies and reports, and only the type checker's first pass over a node uses it.replay_warning_scopeapplies silently, for the type checker's repeated passes (including the second pass over amodule rec), the frontend, translation andInline_not_stored. The~ppwarningflag is gone.replay_warning_scopeover the leading floating attributes. So type checking starts from the command line's warning state, in one-step compiles as in builds.Translmodapplies a floating attribute in a scope around the rest of its structure. It translates the rest of a structure before the item itself, so the scope ends before the items above the attribute are translated. Module bindings,module rec,includeand expression statements get a scope of their attributes, andtransl_expapplies the attributes of type constraints. The scope of aletor module binding also covers the checks of its@inlineattribute (warnings 47, 53 and 54). A newTypedtree.exp_warning_attributescollects those; typemod already needed them for warning 113.Behaviour changes to review. In builds, a leading
@@warning("+102")now enables warning 102, which can newly fail a build that also makes 102 an error. And@warning("-102")now silences 102 on modules,includeand type constraints.Known gaps (both on master already):
@warningon it is still reported twice. Filed as Operands of arithmetic operators are type checked twice #9500.(@warning("-102") type a, x) => …, don't reach translation, because the typed tree doesn't keep them.Tests.
warning_47_warning_payload_once: a malformed payload on@@warning, alet, an expression, a module and amodule rec, a malformed@warnerrorlist, and a@@ppwarning, each now reported once.warning_47_warning_payload_order: a later@@warning("-47")doesn't hide an earlier malformed item.warning_102_attribute_scopes: one comparison in each scope above, nested constraints where the innermost attribute wins, and floating@@warningitems above and inside a module.warning_53_inline_attribute_scope:@warning("-53")covers@inlineon aletand on a module.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gH9cXWp3xtBmfRV3Du