Repository navigation
Conversation
Why:
Builtin_attributes.warning_attribute both applied a warning setting
and reported problems with it. The type checker enters a binding's
warning scope several times, 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 its warning state stayed in place for
the type checker.
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, 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 the warning state is restored before
type checking. The type checker then applies and reports these items in
order, as it already does when a build compiles the parsed .ast file.
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
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>
Why:
Translation to Lambda reports some warnings itself, such as 102 for
a polymorphic comparison. It applies the warning attributes of the
nodes it translates again, but only on let bindings, expressions and
module expressions. It skipped floating @@warning items and the
attributes of module bindings, recursive modules, includes and type
constraints. So `@warning("-102")` on a module did not silence 102
inside it, and in a build `@@warning("+102")` never enabled it.
Translmod now 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 and includes get a scope
of their attributes. 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 (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)
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>
Changelog🐛 Bug fix
Semantic Diff1 commit · Full page Fix
|
|
@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. |
64174bf to
dbe39ca
Compare
|
Folded into #9491, which now fixes the warning attribute handling in one change. |
|
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". |
✅ Compiler benchmarksAllocated wordsIn total: 655,137,777 → 655,157,726 (±0.00%). Generated projects: 627,310,985 → 627,348,013 (+0.01%).
InstructionsIn total: 9,128,180,350 → 9,130,092,818 (+0.02%).
Output sizeIn total: 27,368,588 → 27,369,036 (±0.00%). None of the 13 benchmarks changed by 0.1% or more. Pull request 96f03a3 compared with base 64174bf in this run. |
Stacked on #9491.
Translation to Lambda reports some warnings itself, such as 102 for a polymorphic comparison. It applies the warning attributes of the nodes it translates again, but only on
letbindings, expressions and module expressions. It skipped the others:The same happened for
module rec,include, a type constraint such as@warning("-102") (e: bool), and floating@@warningitems. In a build,@@warning("+102")at the top of a file never enabled 102. A one-stepbsccompile only got it through the frontend's leftover warning state, which #9491 removes.The fix.
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, recursive modules and includes get a scope of their attributes.transl_expalso applies the attributes of type constraints. A newTypedtree.exp_warning_attributescollects them, and typemod uses it for warning 113 too.Tests.
warning_102_attribute_scopeshas one comparison in each of these scopes, plus a floating@@warningabove and inside a module. Without the fix, all eight comparisons are reported; with it, only the two that no attribute silences.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gH9cXWp3xtBmfRV3Du