Skip to content

Commit fdc694b

Browse files
committed
Fix
1 parent f9e78f2 commit fdc694b

11 files changed

Lines changed: 51 additions & 10 deletions

compiler/ml/typemod.ml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,10 @@ and transl_signature env sg =
870870
let trem, rem, final_env = transl_sig newenv srem in
871871
(mksig (Tsig_include incl) env loc :: trem, sg @ rem, final_env)
872872
| Psig_attribute x ->
873-
Builtin_attributes.warning_attribute x;
874-
let trem, rem, final_env = transl_sig env srem in
875-
(mksig (Tsig_attribute x) env loc :: trem, rem, final_env)
873+
Builtin_attributes.warning_scope ~ppwarning:false
874+
~report_attribute_errors:false [x] (fun () ->
875+
let trem, rem, final_env = transl_sig env srem in
876+
(mksig (Tsig_attribute x) env loc :: trem, rem, final_env))
876877
| Psig_extension (ext, _attrs) ->
877878
raise (Error_forward (Builtin_attributes.error_of_extension ext)))
878879
in
@@ -1590,14 +1591,24 @@ and type_structure ?(toplevel = false) funct_body anchor env sstr scope =
15901591
(Tstr_include incl, sg, new_env)
15911592
| Pstr_extension (ext, _attrs) ->
15921593
raise (Error_forward (Builtin_attributes.error_of_extension ext))
1593-
| Pstr_attribute x ->
1594-
Builtin_attributes.warning_attribute x;
1595-
(Tstr_attribute x, [], env)
1594+
| Pstr_attribute x -> (Tstr_attribute x, [], env)
15961595
in
15971596
let rec type_struct env sstr =
15981597
Ctype.init_def (Ident.current_time ());
15991598
match sstr with
16001599
| [] -> ([], [], env)
1600+
| {pstr_desc = Pstr_attribute x; pstr_loc; _} :: srem ->
1601+
let previous_saved_types = Cmt_format.get_saved_types () in
1602+
let str =
1603+
{str_desc = Tstr_attribute x; str_loc = pstr_loc; str_env = env}
1604+
in
1605+
Cmt_format.set_saved_types
1606+
(Cmt_format.Partial_structure_item str :: previous_saved_types);
1607+
let str_rem, sig_rem, final_env =
1608+
Builtin_attributes.warning_scope ~ppwarning:false
1609+
~report_attribute_errors:false [x] (fun () -> type_struct env srem)
1610+
in
1611+
(str :: str_rem, sig_rem, final_env)
16011612
| pstr :: srem ->
16021613
let previous_saved_types = Cmt_format.get_saved_types () in
16031614
let desc, sg, new_env = type_str_item env srem pstr in
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
Warning number 47
3+
/.../fixtures/malformed_warning_attribute.res:1:1-9
4+
5+
1 │ @@warning(123)
6+
2 │
7+
3 │ let x = 1
8+
9+
illegal payload for attribute 'warning'.
10+
A single string literal is expected
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
Warning number 22
3+
/.../fixtures/ppwarning_structure_attribute.res:1:13-19
4+
5+
1 │ @@ppwarning("hello")
6+
2 │
7+
3 │ let x = 1
8+
9+
hello
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
Warning number 102
3+
/.../fixtures/warning102_polymorphic_equality.res:1:19-24
4+
5+
1 │ let f = (a, b) => a == b
6+
2 │
7+
8+
Polymorphic comparison introduced (maybe unsafe)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@@warning(123)
2+
3+
let x = 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@@ppwarning("hello")
2+
3+
let x = 1

0 commit comments

Comments
 (0)