Repository navigation
Commit f71f99a
Fix @warning reported several times and ignored in translation
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 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, 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 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 (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>1 parent 738c317 commit f71f99a
19 files changed
Lines changed: 277 additions & 91 deletions
File tree
- changes
- compiler
- frontend
- typing
- tests/error_tests/single
- expected
- fixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
38 | 36 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
48 | 42 | | |
49 | 43 | | |
50 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| |||
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
47 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
48 | 56 | | |
49 | 57 | | |
50 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
145 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 155 | + | |
| 156 | + | |
155 | 157 | | |
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
159 | | - | |
| 161 | + | |
160 | 162 | | |
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
164 | 166 | | |
165 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
166 | 171 | | |
167 | 172 | | |
168 | | - | |
169 | | - | |
| 173 | + | |
170 | 174 | | |
171 | 175 | | |
172 | | - | |
| 176 | + | |
173 | 177 | | |
174 | 178 | | |
175 | 179 | | |
176 | 180 | | |
177 | 181 | | |
178 | 182 | | |
179 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
180 | 187 | | |
181 | 188 | | |
182 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
64 | 65 | | |
65 | | - | |
66 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
67 | 69 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
74 | 74 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
20 | 19 | | |
21 | 20 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
27 | 24 | | |
28 | 25 | | |
29 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1229 | 1229 | | |
1230 | 1230 | | |
1231 | 1231 | | |
1232 | | - | |
1233 | | - | |
| 1232 | + | |
1234 | 1233 | | |
1235 | 1234 | | |
1236 | 1235 | | |
1237 | | - | |
| 1236 | + | |
1238 | 1237 | | |
1239 | 1238 | | |
1240 | 1239 | | |
| |||
1730 | 1729 | | |
1731 | 1730 | | |
1732 | 1731 | | |
1733 | | - | |
| 1732 | + | |
1734 | 1733 | | |
1735 | 1734 | | |
1736 | 1735 | | |
| |||
1749 | 1748 | | |
1750 | 1749 | | |
1751 | 1750 | | |
1752 | | - | |
1753 | | - | |
| 1751 | + | |
| 1752 | + | |
1754 | 1753 | | |
1755 | 1754 | | |
1756 | 1755 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
253 | | - | |
| 252 | + | |
254 | 253 | | |
255 | 254 | | |
256 | 255 | | |
| |||
392 | 391 | | |
393 | 392 | | |
394 | 393 | | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
400 | 398 | | |
401 | 399 | | |
402 | 400 | | |
| |||
409 | 407 | | |
410 | 408 | | |
411 | 409 | | |
412 | | - | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
| 434 | + | |
| 435 | + | |
435 | 436 | | |
436 | 437 | | |
437 | | - | |
438 | | - | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
439 | 443 | | |
440 | 444 | | |
441 | 445 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1983 | 1983 | | |
1984 | 1984 | | |
1985 | 1985 | | |
1986 | | - | |
1987 | | - | |
| 1986 | + | |
1988 | 1987 | | |
1989 | 1988 | | |
1990 | 1989 | | |
| |||
1995 | 1994 | | |
1996 | 1995 | | |
1997 | 1996 | | |
1998 | | - | |
| 1997 | + | |
1999 | 1998 | | |
2000 | 1999 | | |
2001 | 2000 | | |
| |||
5013 | 5012 | | |
5014 | 5013 | | |
5015 | 5014 | | |
5016 | | - | |
| 5015 | + | |
5017 | 5016 | | |
5018 | 5017 | | |
5019 | 5018 | | |
| |||
5038 | 5037 | | |
5039 | 5038 | | |
5040 | 5039 | | |
5041 | | - | |
| 5040 | + | |
5042 | 5041 | | |
5043 | 5042 | | |
5044 | 5043 | | |
| |||
5118 | 5117 | | |
5119 | 5118 | | |
5120 | 5119 | | |
5121 | | - | |
| 5120 | + | |
5122 | 5121 | | |
5123 | 5122 | | |
5124 | 5123 | | |
5125 | | - | |
| 5124 | + | |
5126 | 5125 | | |
5127 | 5126 | | |
5128 | 5127 | | |
| |||
0 commit comments