Skip to content

Commit aacb207

Browse files
committed
Fix
1 parent ee289bc commit aacb207

21 files changed

+53
-28
lines changed

compiler/frontend/bs_ast_invariant.ml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ type iterator = Ast_iterator.iterator
5050

5151
let super = Ast_iterator.default_iterator
5252

53+
let warning_attribute_iterator =
54+
let structure_item self str_item =
55+
(match str_item.pstr_desc with
56+
| Pstr_attribute attr -> Builtin_attributes.warning_attribute attr
57+
| _ -> ());
58+
super.structure_item self str_item
59+
in
60+
let signature_item self sig_item =
61+
(match sig_item.psig_desc with
62+
| Psig_attribute attr -> Builtin_attributes.warning_attribute attr
63+
| _ -> ());
64+
super.signature_item self sig_item
65+
in
66+
{super with structure_item; signature_item}
67+
5368
let check_constant loc (const : Parsetree.constant) =
5469
match const with
5570
| Pconst_string (_, Some s) ->
@@ -148,28 +163,14 @@ let emit_external_warnings : iterator =
148163
| _ -> super.pat self pat);
149164
}
150165

151-
let rec iter_warnings_on_stru (stru : Parsetree.structure) =
152-
match stru with
153-
| [] -> ()
154-
| head :: rest -> (
155-
match head.pstr_desc with
156-
| Pstr_attribute attr ->
157-
Builtin_attributes.warning_attribute attr;
158-
iter_warnings_on_stru rest
159-
| _ -> ())
166+
let iter_warnings_on_structure (structure : Parsetree.structure) =
167+
warning_attribute_iterator.structure warning_attribute_iterator structure
160168

161-
let rec iter_warnings_on_sigi (stru : Parsetree.signature) =
162-
match stru with
163-
| [] -> ()
164-
| head :: rest -> (
165-
match head.psig_desc with
166-
| Psig_attribute attr ->
167-
Builtin_attributes.warning_attribute attr;
168-
iter_warnings_on_sigi rest
169-
| _ -> ())
169+
let iter_warnings_on_signature (signature : Parsetree.signature) =
170+
warning_attribute_iterator.signature warning_attribute_iterator signature
170171

171-
let emit_external_warnings_on_structure (stru : Parsetree.structure) =
172-
emit_external_warnings.structure emit_external_warnings stru
172+
let emit_external_warnings_on_structure (structure : Parsetree.structure) =
173+
emit_external_warnings.structure emit_external_warnings structure
173174

174-
let emit_external_warnings_on_signature (sigi : Parsetree.signature) =
175-
emit_external_warnings.signature emit_external_warnings sigi
175+
let emit_external_warnings_on_signature (signature : Parsetree.signature) =
176+
emit_external_warnings.signature emit_external_warnings signature

compiler/frontend/bs_ast_invariant.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ type iterator = Ast_iterator.iterator
3030
val warn_discarded_unused_attributes : Parsetree.attributes -> unit
3131
(** Ast invariant checking for detecting errors *)
3232

33-
val iter_warnings_on_stru : Parsetree.structure -> unit
33+
val iter_warnings_on_structure : Parsetree.structure -> unit
3434

35-
val iter_warnings_on_sigi : Parsetree.signature -> unit
35+
val iter_warnings_on_signature : Parsetree.signature -> unit
3636

3737
val emit_external_warnings_on_structure : Parsetree.structure -> unit
3838

compiler/frontend/ppx_entry.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
let unsafe_mapper = Bs_builtin_ppx.mapper
2626

2727
let rewrite_signature (ast : Parsetree.signature) : Parsetree.signature =
28-
Bs_ast_invariant.iter_warnings_on_sigi ast;
28+
Bs_ast_invariant.iter_warnings_on_signature ast;
2929
Ast_config.process_sig ast;
3030
let ast =
3131
match !Js_config.jsx_version with
@@ -44,7 +44,7 @@ let rewrite_signature (ast : Parsetree.signature) : Parsetree.signature =
4444
result
4545

4646
let rewrite_implementation (ast : Parsetree.structure) : Parsetree.structure =
47-
Bs_ast_invariant.iter_warnings_on_stru ast;
47+
Bs_ast_invariant.iter_warnings_on_structure ast;
4848
Ast_config.process_str ast;
4949
let ast =
5050
match !Js_config.jsx_version with

tests/build_tests/super_errors/expected/malformed_warning_attribute.resi.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
3 │ let x: int
88

99
illegal payload for attribute 'warning'.
10-
A single string literal is expected
10+
A single string literal is expected

tests/build_tests/super_errors/expected/nested_malformed_warning_signature_attribute.resi.expected

Whitespace-only changes.

tests/build_tests/super_errors/expected/nested_malformed_warning_structure_attribute.res.expected

Whitespace-only changes.

tests/build_tests/super_errors/expected/nested_ppwarning_signature_attribute.resi.expected

Whitespace-only changes.

tests/build_tests/super_errors/expected/nested_ppwarning_structure_attribute.res.expected

Whitespace-only changes.

tests/build_tests/super_errors/expected/nonleading_malformed_warning_signature_attribute.resi.expected

Whitespace-only changes.

tests/build_tests/super_errors/expected/nonleading_malformed_warning_structure_attribute.res.expected

Whitespace-only changes.

0 commit comments

Comments
 (0)