From 8f4f487f3f81c8d0d8a1afc316fd6ff86fcbb4b0 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Thu, 2 Apr 2026 17:42:41 +0200 Subject: [PATCH 1/8] Fix @warning("-102") not working --- compiler/core/lam_compile_primitive.ml | 4 --- compiler/ml/builtin_attributes.ml | 19 ++++++++------ compiler/ml/builtin_attributes.mli | 16 ++++++++++-- compiler/ml/translcore.ml | 25 ++++++++++++++----- compiler/ml/translmod.ml | 7 ++++-- .../warning102_expr_attribute.res.expected | 1 + ...arning102_structure_attribute.res.expected | 1 + .../warning102_value_attribute.res.expected | 1 + .../fixtures/warning102_expr_attribute.res | 3 +++ .../warning102_structure_attribute.res | 3 +++ .../fixtures/warning102_value_attribute.res | 1 + 11 files changed, 60 insertions(+), 21 deletions(-) create mode 100644 tests/build_tests/super_errors/expected/warning102_expr_attribute.res.expected create mode 100644 tests/build_tests/super_errors/expected/warning102_structure_attribute.res.expected create mode 100644 tests/build_tests/super_errors/expected/warning102_value_attribute.res.expected create mode 100644 tests/build_tests/super_errors/fixtures/warning102_expr_attribute.res create mode 100644 tests/build_tests/super_errors/fixtures/warning102_structure_attribute.res create mode 100644 tests/build_tests/super_errors/fixtures/warning102_value_attribute.res diff --git a/compiler/core/lam_compile_primitive.ml b/compiler/core/lam_compile_primitive.ml index e7c377e97a7..47aabff81a3 100644 --- a/compiler/core/lam_compile_primitive.ml +++ b/compiler/core/lam_compile_primitive.ml @@ -389,23 +389,19 @@ let translate output_prefix loc (cxt : Lam_compile_context.t) || E.is_null_undefined_constant e2) -> E.neq_null_undefined_boolean e1 e2 | [e1; e2] -> - Location.prerr_warning loc Warnings.Bs_polymorphic_comparison; E.runtime_call Primitive_modules.object_ (Lam_compile_util.runtime_of_comp cmp) args | _ -> assert false) | Pobjorder -> ( - Location.prerr_warning loc Warnings.Bs_polymorphic_comparison; match args with | [a; b] -> E.runtime_call Primitive_modules.object_ "compare" args | _ -> assert false) | Pobjmin -> ( - Location.prerr_warning loc Warnings.Bs_polymorphic_comparison; match args with | [a; b] -> E.runtime_call Primitive_modules.object_ "min" args | _ -> assert false) | Pobjmax -> ( - Location.prerr_warning loc Warnings.Bs_polymorphic_comparison; match args with | [a; b] -> E.runtime_call Primitive_modules.object_ "max" args | _ -> assert false) diff --git a/compiler/ml/builtin_attributes.ml b/compiler/ml/builtin_attributes.ml index a4d073104b4..a1c9aa5514a 100644 --- a/compiler/ml/builtin_attributes.ml +++ b/compiler/ml/builtin_attributes.ml @@ -182,17 +182,20 @@ let rec deprecated_of_str = function | Some _ as r -> r) | _ -> None -let warning_attribute ?(ppwarning = true) = +let warning_attribute ?(ppwarning = true) ?(report_attribute_errors = true) = let process loc txt errflag payload = match string_of_payload payload with | Some s -> ( try Warnings.parse_options errflag s with Arg.Bad _ -> - Location.prerr_warning loc - (Warnings.Attribute_payload (txt, "Ill-formed list of warnings"))) + if report_attribute_errors then + Location.prerr_warning loc + (Warnings.Attribute_payload (txt, "Ill-formed list of warnings"))) | None -> - Location.prerr_warning loc - (Warnings.Attribute_payload (txt, "A single string literal is expected")) + if report_attribute_errors then + Location.prerr_warning loc + (Warnings.Attribute_payload + (txt, "A single string literal is expected")) in function | {txt = ("ocaml.warning" | "warning") as txt; loc}, payload -> @@ -212,10 +215,12 @@ let warning_attribute ?(ppwarning = true) = Location.prerr_warning pstr_loc (Warnings.Preprocessor s) | _ -> () -let warning_scope ?ppwarning attrs f = +let warning_scope ?ppwarning ?report_attribute_errors attrs f = let prev = Warnings.backup () in try - List.iter (warning_attribute ?ppwarning) (List.rev attrs); + List.iter + (warning_attribute ?ppwarning ?report_attribute_errors) + (List.rev attrs); let ret = f () in Warnings.restore prev; ret diff --git a/compiler/ml/builtin_attributes.mli b/compiler/ml/builtin_attributes.mli index 63bf7623315..dc2bf958e40 100644 --- a/compiler/ml/builtin_attributes.mli +++ b/compiler/ml/builtin_attributes.mli @@ -67,17 +67,29 @@ val check_duplicated_labels : (Parsetree.label_declaration list -> string Asttypes.loc option) ref val error_of_extension : Parsetree.extension -> Location.error -val warning_attribute : ?ppwarning:bool -> Parsetree.attribute -> unit +val warning_attribute : + ?ppwarning:bool -> + ?report_attribute_errors:bool -> + Parsetree.attribute -> + unit (** Apply warning settings from the specified attribute. "ocaml.warning"/"ocaml.warnerror" (and variants without the prefix) are processed and other attributes are ignored. Also implement ocaml.ppwarning (unless ~ppwarning:false is passed). + + [report_attribute_errors] only controls whether malformed warning + attributes emit diagnostics; valid warning settings are still applied + regardless. *) val warning_scope : - ?ppwarning:bool -> Parsetree.attributes -> (unit -> 'a) -> 'a + ?ppwarning:bool -> + ?report_attribute_errors:bool -> + Parsetree.attributes -> + (unit -> 'a) -> + 'a (** Execute a function in a new scope for warning settings. This means that the effect of any call to [warning_attribute] during the execution of this function will be discarded after diff --git a/compiler/ml/translcore.ml b/compiler/ml/translcore.ml index 078cbf133a0..3d7ba5029c9 100644 --- a/compiler/ml/translcore.ml +++ b/compiler/ml/translcore.ml @@ -404,6 +404,15 @@ let primitives_table = let find_primitive prim_name = Hashtbl.find primitives_table prim_name +let warn_on_polymorphic_comparison loc = function + | Pobjcomp _ | Pobjorder | Pobjmin | Pobjmax -> + Location.prerr_warning loc Warnings.Bs_polymorphic_comparison + | _ -> () + +let emit_primitive_warnings loc primitive = + warn_on_polymorphic_comparison loc primitive; + primitive + let specialize_comparison ({objcomp; intcomp; floatcomp; stringcomp; bigintcomp; boolcomp} : specialized) env ty = @@ -444,8 +453,9 @@ let specialize_primitive p env ty (* ~has_constant_constructor *) = let transl_primitive loc p env ty = (* Printf.eprintf "----transl_primitive %s----\n" p.prim_name; *) let prim = - try specialize_primitive p env ty (* ~has_constant_constructor:false *) - with Not_found -> Pccall p + (try specialize_primitive p env ty (* ~has_constant_constructor:false *) + with Not_found -> Pccall p) + |> emit_primitive_warnings loc in match prim with | Ploc kind -> ( @@ -492,7 +502,7 @@ let transl_primitive_application loc prim env ty args = | [arg1] | [arg1; _] -> translate_unified_ops prim env arg1.exp_type | _ -> None in - match unified with + (match unified with | Some primitive -> primitive | None -> ( try @@ -524,7 +534,8 @@ let transl_primitive_application loc prim env ty args = with Not_found -> if String.length prim_name > 0 && prim_name.[0] = '%' then raise (Error (loc, Unknown_builtin_primitive prim_name)); - Pccall prim) + Pccall prim)) + |> emit_primitive_warnings loc (* To propagate structured constants *) @@ -653,8 +664,10 @@ let extract_directive_for_fn exp = else None) let rec transl_exp e = - List.iter (Translattribute.check_attribute e) e.exp_attributes; - transl_exp0 e + Builtin_attributes.warning_scope ~ppwarning:false + ~report_attribute_errors:false e.exp_attributes (fun () -> + List.iter (Translattribute.check_attribute e) e.exp_attributes; + transl_exp0 e) and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = match e.exp_desc with diff --git a/compiler/ml/translmod.ml b/compiler/ml/translmod.ml index 87471ac26bf..729a520e2f7 100644 --- a/compiler/ml/translmod.ml +++ b/compiler/ml/translmod.ml @@ -446,8 +446,11 @@ and transl_structure loc fields cc rootpath final_env = function transl_module Tcoerce_none None modl, body ), size ) - | Tstr_primitive _ | Tstr_type _ | Tstr_modtype _ | Tstr_open _ - | Tstr_attribute _ -> + | Tstr_primitive _ | Tstr_type _ | Tstr_modtype _ | Tstr_open _ -> + transl_structure loc fields cc rootpath final_env rem + | Tstr_attribute x -> + Builtin_attributes.warning_attribute ~ppwarning:false + ~report_attribute_errors:false x; transl_structure loc fields cc rootpath final_env rem) (* Update forward declaration in Translcore *) diff --git a/tests/build_tests/super_errors/expected/warning102_expr_attribute.res.expected b/tests/build_tests/super_errors/expected/warning102_expr_attribute.res.expected new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/tests/build_tests/super_errors/expected/warning102_expr_attribute.res.expected @@ -0,0 +1 @@ + diff --git a/tests/build_tests/super_errors/expected/warning102_structure_attribute.res.expected b/tests/build_tests/super_errors/expected/warning102_structure_attribute.res.expected new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/tests/build_tests/super_errors/expected/warning102_structure_attribute.res.expected @@ -0,0 +1 @@ + diff --git a/tests/build_tests/super_errors/expected/warning102_value_attribute.res.expected b/tests/build_tests/super_errors/expected/warning102_value_attribute.res.expected new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/tests/build_tests/super_errors/expected/warning102_value_attribute.res.expected @@ -0,0 +1 @@ + diff --git a/tests/build_tests/super_errors/fixtures/warning102_expr_attribute.res b/tests/build_tests/super_errors/fixtures/warning102_expr_attribute.res new file mode 100644 index 00000000000..9bec0b9afbd --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/warning102_expr_attribute.res @@ -0,0 +1,3 @@ +let x = (a, b) => { + @warning("-102") (a->Pair.second > b->Pair.second) +} diff --git a/tests/build_tests/super_errors/fixtures/warning102_structure_attribute.res b/tests/build_tests/super_errors/fixtures/warning102_structure_attribute.res new file mode 100644 index 00000000000..d0ddc537322 --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/warning102_structure_attribute.res @@ -0,0 +1,3 @@ +@@warning("-102") + +let x = (a, b) => a->Pair.second > b->Pair.second diff --git a/tests/build_tests/super_errors/fixtures/warning102_value_attribute.res b/tests/build_tests/super_errors/fixtures/warning102_value_attribute.res new file mode 100644 index 00000000000..1fb1a49b850 --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/warning102_value_attribute.res @@ -0,0 +1 @@ +let v = @warning("-102") compare From 165476741a937db43181f5ccd07046dcd671adb4 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Thu, 2 Apr 2026 20:32:31 +0200 Subject: [PATCH 2/8] fix --- compiler/ml/translmod.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/ml/translmod.ml b/compiler/ml/translmod.ml index 729a520e2f7..595bc912f2b 100644 --- a/compiler/ml/translmod.ml +++ b/compiler/ml/translmod.ml @@ -449,9 +449,9 @@ and transl_structure loc fields cc rootpath final_env = function | Tstr_primitive _ | Tstr_type _ | Tstr_modtype _ | Tstr_open _ -> transl_structure loc fields cc rootpath final_env rem | Tstr_attribute x -> - Builtin_attributes.warning_attribute ~ppwarning:false - ~report_attribute_errors:false x; - transl_structure loc fields cc rootpath final_env rem) + Builtin_attributes.warning_scope ~ppwarning:false + ~report_attribute_errors:false [x] (fun () -> + transl_structure loc fields cc rootpath final_env rem)) (* Update forward declaration in Translcore *) let _ = Translcore.transl_module := transl_module From f9e78f2c2a1961170297d35141acc3be87a7f93a Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Fri, 3 Apr 2026 08:37:07 +0200 Subject: [PATCH 3/8] Fix --- compiler/ml/translcore.ml | 32 ++++++++++++++++--- .../warning102_nullish_equality.res.expected | 1 + .../fixtures/warning102_nullish_equality.res | 8 +++++ 3 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 tests/build_tests/super_errors/expected/warning102_nullish_equality.res.expected create mode 100644 tests/build_tests/super_errors/fixtures/warning102_nullish_equality.res diff --git a/compiler/ml/translcore.ml b/compiler/ml/translcore.ml index 3d7ba5029c9..16d742d694b 100644 --- a/compiler/ml/translcore.ml +++ b/compiler/ml/translcore.ml @@ -404,13 +404,35 @@ let primitives_table = let find_primitive prim_name = Hashtbl.find primitives_table prim_name -let warn_on_polymorphic_comparison loc = function +let is_null_undefined_constant (exp : Typedtree.expression) = + match exp.exp_desc with + | Texp_ident + ( _, + _, + { + val_kind = + Val_prim + {prim_name = "%null" | "%undefined" | "#null" | "#undefined"; _}; + _; + } ) -> + true + | _ -> false + +let warn_on_polymorphic_comparison loc prim_name args = function + (* Preserve the backend's old exemption for == / != against nullish constants, + which compile to dedicated null/undefined checks rather than object compare. *) + | Pobjcomp (Ceq | Cneq) + when prim_name = "%equal_null" + || prim_name = "%equal_undefined" + || prim_name = "%equal_nullable" + || List.exists is_null_undefined_constant args -> + () | Pobjcomp _ | Pobjorder | Pobjmin | Pobjmax -> Location.prerr_warning loc Warnings.Bs_polymorphic_comparison | _ -> () -let emit_primitive_warnings loc primitive = - warn_on_polymorphic_comparison loc primitive; +let emit_primitive_warnings loc prim_name args primitive = + warn_on_polymorphic_comparison loc prim_name args primitive; primitive let specialize_comparison @@ -455,7 +477,7 @@ let transl_primitive loc p env ty = let prim = (try specialize_primitive p env ty (* ~has_constant_constructor:false *) with Not_found -> Pccall p) - |> emit_primitive_warnings loc + |> emit_primitive_warnings loc p.prim_name [] in match prim with | Ploc kind -> ( @@ -535,7 +557,7 @@ let transl_primitive_application loc prim env ty args = if String.length prim_name > 0 && prim_name.[0] = '%' then raise (Error (loc, Unknown_builtin_primitive prim_name)); Pccall prim)) - |> emit_primitive_warnings loc + |> emit_primitive_warnings loc prim_name args (* To propagate structured constants *) diff --git a/tests/build_tests/super_errors/expected/warning102_nullish_equality.res.expected b/tests/build_tests/super_errors/expected/warning102_nullish_equality.res.expected new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/tests/build_tests/super_errors/expected/warning102_nullish_equality.res.expected @@ -0,0 +1 @@ + diff --git a/tests/build_tests/super_errors/fixtures/warning102_nullish_equality.res b/tests/build_tests/super_errors/fixtures/warning102_nullish_equality.res new file mode 100644 index 00000000000..c14079e0403 --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/warning102_nullish_equality.res @@ -0,0 +1,8 @@ +let undefinedEq = undefined == undefined +let undefinedNeq = undefined != undefined + +let nullEq = null == null +let nullNeq = null != null + +let nullableEq = Nullable.undefined == Nullable.make(3) +let nullableNeq = Nullable.undefined != Nullable.make(3) From fdc694b0cc0cdf40edab87295b4eba32e8ec4fef Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Fri, 3 Apr 2026 09:11:23 +0200 Subject: [PATCH 4/8] Fix --- compiler/ml/typemod.ml | 23 ++++++++++++++----- .../malformed_warning_attribute.res.expected | 10 ++++++++ ...ppwarning_structure_attribute.res.expected | 9 ++++++++ .../warning102_expr_attribute.res.expected | 1 - .../warning102_nullish_equality.res.expected | 1 - ...rning102_polymorphic_equality.res.expected | 8 +++++++ ...arning102_structure_attribute.res.expected | 1 - .../warning102_value_attribute.res.expected | 1 - .../fixtures/malformed_warning_attribute.res | 3 +++ .../ppwarning_structure_attribute.res | 3 +++ .../warning102_polymorphic_equality.res | 1 + 11 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 tests/build_tests/super_errors/expected/malformed_warning_attribute.res.expected create mode 100644 tests/build_tests/super_errors/expected/ppwarning_structure_attribute.res.expected create mode 100644 tests/build_tests/super_errors/expected/warning102_polymorphic_equality.res.expected create mode 100644 tests/build_tests/super_errors/fixtures/malformed_warning_attribute.res create mode 100644 tests/build_tests/super_errors/fixtures/ppwarning_structure_attribute.res create mode 100644 tests/build_tests/super_errors/fixtures/warning102_polymorphic_equality.res diff --git a/compiler/ml/typemod.ml b/compiler/ml/typemod.ml index 0932c62f347..f94898c05fa 100644 --- a/compiler/ml/typemod.ml +++ b/compiler/ml/typemod.ml @@ -870,9 +870,10 @@ and transl_signature env sg = let trem, rem, final_env = transl_sig newenv srem in (mksig (Tsig_include incl) env loc :: trem, sg @ rem, final_env) | Psig_attribute x -> - Builtin_attributes.warning_attribute x; - let trem, rem, final_env = transl_sig env srem in - (mksig (Tsig_attribute x) env loc :: trem, rem, final_env) + Builtin_attributes.warning_scope ~ppwarning:false + ~report_attribute_errors:false [x] (fun () -> + let trem, rem, final_env = transl_sig env srem in + (mksig (Tsig_attribute x) env loc :: trem, rem, final_env)) | Psig_extension (ext, _attrs) -> raise (Error_forward (Builtin_attributes.error_of_extension ext))) in @@ -1590,14 +1591,24 @@ and type_structure ?(toplevel = false) funct_body anchor env sstr scope = (Tstr_include incl, sg, new_env) | Pstr_extension (ext, _attrs) -> raise (Error_forward (Builtin_attributes.error_of_extension ext)) - | Pstr_attribute x -> - Builtin_attributes.warning_attribute x; - (Tstr_attribute x, [], env) + | Pstr_attribute x -> (Tstr_attribute x, [], env) in let rec type_struct env sstr = Ctype.init_def (Ident.current_time ()); match sstr with | [] -> ([], [], env) + | {pstr_desc = Pstr_attribute x; pstr_loc; _} :: srem -> + let previous_saved_types = Cmt_format.get_saved_types () in + let str = + {str_desc = Tstr_attribute x; str_loc = pstr_loc; str_env = env} + in + Cmt_format.set_saved_types + (Cmt_format.Partial_structure_item str :: previous_saved_types); + let str_rem, sig_rem, final_env = + Builtin_attributes.warning_scope ~ppwarning:false + ~report_attribute_errors:false [x] (fun () -> type_struct env srem) + in + (str :: str_rem, sig_rem, final_env) | pstr :: srem -> let previous_saved_types = Cmt_format.get_saved_types () in let desc, sg, new_env = type_str_item env srem pstr in diff --git a/tests/build_tests/super_errors/expected/malformed_warning_attribute.res.expected b/tests/build_tests/super_errors/expected/malformed_warning_attribute.res.expected new file mode 100644 index 00000000000..428a538da67 --- /dev/null +++ b/tests/build_tests/super_errors/expected/malformed_warning_attribute.res.expected @@ -0,0 +1,10 @@ + + Warning number 47 + /.../fixtures/malformed_warning_attribute.res:1:1-9 + + 1 │ @@warning(123) + 2 │ + 3 │ let x = 1 + + illegal payload for attribute 'warning'. +A single string literal is expected \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/ppwarning_structure_attribute.res.expected b/tests/build_tests/super_errors/expected/ppwarning_structure_attribute.res.expected new file mode 100644 index 00000000000..3ff8ada406b --- /dev/null +++ b/tests/build_tests/super_errors/expected/ppwarning_structure_attribute.res.expected @@ -0,0 +1,9 @@ + + Warning number 22 + /.../fixtures/ppwarning_structure_attribute.res:1:13-19 + + 1 │ @@ppwarning("hello") + 2 │ + 3 │ let x = 1 + + hello \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/warning102_expr_attribute.res.expected b/tests/build_tests/super_errors/expected/warning102_expr_attribute.res.expected index 8b137891791..e69de29bb2d 100644 --- a/tests/build_tests/super_errors/expected/warning102_expr_attribute.res.expected +++ b/tests/build_tests/super_errors/expected/warning102_expr_attribute.res.expected @@ -1 +0,0 @@ - diff --git a/tests/build_tests/super_errors/expected/warning102_nullish_equality.res.expected b/tests/build_tests/super_errors/expected/warning102_nullish_equality.res.expected index 8b137891791..e69de29bb2d 100644 --- a/tests/build_tests/super_errors/expected/warning102_nullish_equality.res.expected +++ b/tests/build_tests/super_errors/expected/warning102_nullish_equality.res.expected @@ -1 +0,0 @@ - diff --git a/tests/build_tests/super_errors/expected/warning102_polymorphic_equality.res.expected b/tests/build_tests/super_errors/expected/warning102_polymorphic_equality.res.expected new file mode 100644 index 00000000000..98c7b2fb391 --- /dev/null +++ b/tests/build_tests/super_errors/expected/warning102_polymorphic_equality.res.expected @@ -0,0 +1,8 @@ + + Warning number 102 + /.../fixtures/warning102_polymorphic_equality.res:1:19-24 + + 1 │ let f = (a, b) => a == b + 2 │ + + Polymorphic comparison introduced (maybe unsafe) \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/warning102_structure_attribute.res.expected b/tests/build_tests/super_errors/expected/warning102_structure_attribute.res.expected index 8b137891791..e69de29bb2d 100644 --- a/tests/build_tests/super_errors/expected/warning102_structure_attribute.res.expected +++ b/tests/build_tests/super_errors/expected/warning102_structure_attribute.res.expected @@ -1 +0,0 @@ - diff --git a/tests/build_tests/super_errors/expected/warning102_value_attribute.res.expected b/tests/build_tests/super_errors/expected/warning102_value_attribute.res.expected index 8b137891791..e69de29bb2d 100644 --- a/tests/build_tests/super_errors/expected/warning102_value_attribute.res.expected +++ b/tests/build_tests/super_errors/expected/warning102_value_attribute.res.expected @@ -1 +0,0 @@ - diff --git a/tests/build_tests/super_errors/fixtures/malformed_warning_attribute.res b/tests/build_tests/super_errors/fixtures/malformed_warning_attribute.res new file mode 100644 index 00000000000..3951cf99fc1 --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/malformed_warning_attribute.res @@ -0,0 +1,3 @@ +@@warning(123) + +let x = 1 diff --git a/tests/build_tests/super_errors/fixtures/ppwarning_structure_attribute.res b/tests/build_tests/super_errors/fixtures/ppwarning_structure_attribute.res new file mode 100644 index 00000000000..7d21223a7a9 --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/ppwarning_structure_attribute.res @@ -0,0 +1,3 @@ +@@ppwarning("hello") + +let x = 1 diff --git a/tests/build_tests/super_errors/fixtures/warning102_polymorphic_equality.res b/tests/build_tests/super_errors/fixtures/warning102_polymorphic_equality.res new file mode 100644 index 00000000000..16c9337f925 --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/warning102_polymorphic_equality.res @@ -0,0 +1 @@ +let f = (a, b) => a == b From b73831974dbb5445a09a7630bcc8954e8be88fcd Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Fri, 3 Apr 2026 09:21:36 +0200 Subject: [PATCH 5/8] .resi tests --- compiler/ml/typemod.ml | 5 +++++ .../expected/malformed_warning_attribute.resi.expected | 10 ++++++++++ .../ppwarning_signature_attribute.resi.expected | 9 +++++++++ .../fixtures/malformed_warning_attribute.resi | 3 +++ .../fixtures/ppwarning_signature_attribute.resi | 3 +++ tests/build_tests/super_errors/input.js | 2 +- 6 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/build_tests/super_errors/expected/malformed_warning_attribute.resi.expected create mode 100644 tests/build_tests/super_errors/expected/ppwarning_signature_attribute.resi.expected create mode 100644 tests/build_tests/super_errors/fixtures/malformed_warning_attribute.resi create mode 100644 tests/build_tests/super_errors/fixtures/ppwarning_signature_attribute.resi diff --git a/compiler/ml/typemod.ml b/compiler/ml/typemod.ml index f94898c05fa..db0524adc39 100644 --- a/compiler/ml/typemod.ml +++ b/compiler/ml/typemod.ml @@ -870,6 +870,9 @@ and transl_signature env sg = let trem, rem, final_env = transl_sig newenv srem in (mksig (Tsig_include incl) env loc :: trem, sg @ rem, final_env) | Psig_attribute x -> + (* The frontend pre-pass already emitted @@ppwarning and malformed + @@warning diagnostics; only thread the warning state here so the + remaining signature items see the right settings. *) Builtin_attributes.warning_scope ~ppwarning:false ~report_attribute_errors:false [x] (fun () -> let trem, rem, final_env = transl_sig env srem in @@ -1605,6 +1608,8 @@ and type_structure ?(toplevel = false) funct_body anchor env sstr scope = Cmt_format.set_saved_types (Cmt_format.Partial_structure_item str :: previous_saved_types); let str_rem, sig_rem, final_env = + (* Floating warning-attribute diagnostics are handled in the frontend + pass; this scope only applies their effect to following items. *) Builtin_attributes.warning_scope ~ppwarning:false ~report_attribute_errors:false [x] (fun () -> type_struct env srem) in diff --git a/tests/build_tests/super_errors/expected/malformed_warning_attribute.resi.expected b/tests/build_tests/super_errors/expected/malformed_warning_attribute.resi.expected new file mode 100644 index 00000000000..489b10a0603 --- /dev/null +++ b/tests/build_tests/super_errors/expected/malformed_warning_attribute.resi.expected @@ -0,0 +1,10 @@ + + Warning number 47 + /.../fixtures/malformed_warning_attribute.resi:1:1-9 + + 1 │ @@warning(123) + 2 │ + 3 │ let x: int + + illegal payload for attribute 'warning'. +A single string literal is expected diff --git a/tests/build_tests/super_errors/expected/ppwarning_signature_attribute.resi.expected b/tests/build_tests/super_errors/expected/ppwarning_signature_attribute.resi.expected new file mode 100644 index 00000000000..ca0612eab85 --- /dev/null +++ b/tests/build_tests/super_errors/expected/ppwarning_signature_attribute.resi.expected @@ -0,0 +1,9 @@ + + Warning number 22 + /.../fixtures/ppwarning_signature_attribute.resi:1:13-19 + + 1 │ @@ppwarning("hello") + 2 │ + 3 │ let x: int + + hello diff --git a/tests/build_tests/super_errors/fixtures/malformed_warning_attribute.resi b/tests/build_tests/super_errors/fixtures/malformed_warning_attribute.resi new file mode 100644 index 00000000000..cd7eec4e6c1 --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/malformed_warning_attribute.resi @@ -0,0 +1,3 @@ +@@warning(123) + +let x: int diff --git a/tests/build_tests/super_errors/fixtures/ppwarning_signature_attribute.resi b/tests/build_tests/super_errors/fixtures/ppwarning_signature_attribute.resi new file mode 100644 index 00000000000..95597ae052d --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/ppwarning_signature_attribute.resi @@ -0,0 +1,3 @@ +@@ppwarning("hello") + +let x: int diff --git a/tests/build_tests/super_errors/input.js b/tests/build_tests/super_errors/input.js index 3ea9e08c68d..822428371ca 100644 --- a/tests/build_tests/super_errors/input.js +++ b/tests/build_tests/super_errors/input.js @@ -11,7 +11,7 @@ const { bsc } = setup(import.meta.dirname); const expectedDir = path.join(import.meta.dirname, "expected"); const fixtures = readdirSync(path.join(import.meta.dirname, "fixtures")).filter( - fileName => path.extname(fileName) === ".res", + fileName => [".res", ".resi"].includes(path.extname(fileName)), ); const prefix = ["-w", "+A", "-bs-jsx", "4"]; From a937c43f73f7dfba353086ecd96490094180a16c Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Fri, 3 Apr 2026 09:52:08 +0200 Subject: [PATCH 6/8] Simplify --- compiler/ml/builtin_attributes.ml | 3 +++ compiler/ml/builtin_attributes.mli | 8 ++++++++ compiler/ml/translcore.ml | 4 ++-- compiler/ml/translmod.ml | 5 ++--- compiler/ml/typemod.ml | 13 ++++--------- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/compiler/ml/builtin_attributes.ml b/compiler/ml/builtin_attributes.ml index a1c9aa5514a..c3e3b93411d 100644 --- a/compiler/ml/builtin_attributes.ml +++ b/compiler/ml/builtin_attributes.ml @@ -228,6 +228,9 @@ let warning_scope ?ppwarning ?report_attribute_errors attrs f = Warnings.restore prev; raise exn +let warning_scope_without_attribute_diagnostics attrs f = + warning_scope ~ppwarning:false ~report_attribute_errors:false attrs f + let warn_on_literal_pattern = List.exists (function | {txt = "ocaml.warn_on_literal_pattern" | "warn_on_literal_pattern"; _}, _ diff --git a/compiler/ml/builtin_attributes.mli b/compiler/ml/builtin_attributes.mli index dc2bf958e40..aa6282749a5 100644 --- a/compiler/ml/builtin_attributes.mli +++ b/compiler/ml/builtin_attributes.mli @@ -100,6 +100,14 @@ val warning_scope : is executed. *) +val warning_scope_without_attribute_diagnostics : + Parsetree.attributes -> (unit -> 'a) -> 'a +(** Like [warning_scope], but suppresses diagnostics that have already been + emitted during the frontend warning-attribute pass (such as + [@@ppwarning] and malformed warning payloads). The warning settings are + still applied to the nested computation. + *) + val warn_on_literal_pattern : Parsetree.attributes -> bool val explicit_arity : Parsetree.attributes -> bool diff --git a/compiler/ml/translcore.ml b/compiler/ml/translcore.ml index 16d742d694b..826e3773641 100644 --- a/compiler/ml/translcore.ml +++ b/compiler/ml/translcore.ml @@ -686,8 +686,8 @@ let extract_directive_for_fn exp = else None) let rec transl_exp e = - Builtin_attributes.warning_scope ~ppwarning:false - ~report_attribute_errors:false e.exp_attributes (fun () -> + Builtin_attributes.warning_scope_without_attribute_diagnostics + e.exp_attributes (fun () -> List.iter (Translattribute.check_attribute e) e.exp_attributes; transl_exp0 e) diff --git a/compiler/ml/translmod.ml b/compiler/ml/translmod.ml index 595bc912f2b..dd1bc533a1c 100644 --- a/compiler/ml/translmod.ml +++ b/compiler/ml/translmod.ml @@ -449,9 +449,8 @@ and transl_structure loc fields cc rootpath final_env = function | Tstr_primitive _ | Tstr_type _ | Tstr_modtype _ | Tstr_open _ -> transl_structure loc fields cc rootpath final_env rem | Tstr_attribute x -> - Builtin_attributes.warning_scope ~ppwarning:false - ~report_attribute_errors:false [x] (fun () -> - transl_structure loc fields cc rootpath final_env rem)) + Builtin_attributes.warning_scope_without_attribute_diagnostics [x] + (fun () -> transl_structure loc fields cc rootpath final_env rem)) (* Update forward declaration in Translcore *) let _ = Translcore.transl_module := transl_module diff --git a/compiler/ml/typemod.ml b/compiler/ml/typemod.ml index db0524adc39..c88c7201637 100644 --- a/compiler/ml/typemod.ml +++ b/compiler/ml/typemod.ml @@ -870,11 +870,8 @@ and transl_signature env sg = let trem, rem, final_env = transl_sig newenv srem in (mksig (Tsig_include incl) env loc :: trem, sg @ rem, final_env) | Psig_attribute x -> - (* The frontend pre-pass already emitted @@ppwarning and malformed - @@warning diagnostics; only thread the warning state here so the - remaining signature items see the right settings. *) - Builtin_attributes.warning_scope ~ppwarning:false - ~report_attribute_errors:false [x] (fun () -> + Builtin_attributes.warning_scope_without_attribute_diagnostics [x] + (fun () -> let trem, rem, final_env = transl_sig env srem in (mksig (Tsig_attribute x) env loc :: trem, rem, final_env)) | Psig_extension (ext, _attrs) -> @@ -1608,10 +1605,8 @@ and type_structure ?(toplevel = false) funct_body anchor env sstr scope = Cmt_format.set_saved_types (Cmt_format.Partial_structure_item str :: previous_saved_types); let str_rem, sig_rem, final_env = - (* Floating warning-attribute diagnostics are handled in the frontend - pass; this scope only applies their effect to following items. *) - Builtin_attributes.warning_scope ~ppwarning:false - ~report_attribute_errors:false [x] (fun () -> type_struct env srem) + Builtin_attributes.warning_scope_without_attribute_diagnostics [x] + (fun () -> type_struct env srem) in (str :: str_rem, sig_rem, final_env) | pstr :: srem -> From ee289bc63d877820df080313c2a811a53bc48f82 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Fri, 3 Apr 2026 10:29:28 +0200 Subject: [PATCH 7/8] Update comment --- compiler/ml/translcore.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/ml/translcore.ml b/compiler/ml/translcore.ml index 826e3773641..42ed7a23a9f 100644 --- a/compiler/ml/translcore.ml +++ b/compiler/ml/translcore.ml @@ -419,8 +419,8 @@ let is_null_undefined_constant (exp : Typedtree.expression) = | _ -> false let warn_on_polymorphic_comparison loc prim_name args = function - (* Preserve the backend's old exemption for == / != against nullish constants, - which compile to dedicated null/undefined checks rather than object compare. *) + (* Skip warning 102 for `==` / `!=` when one side is a nullish constant: + those cases lower to dedicated null/undefined checks, not object comparison. *) | Pobjcomp (Ceq | Cneq) when prim_name = "%equal_null" || prim_name = "%equal_undefined" From c4f4a87c2d818c33def297610e4b34f5ab01f48b Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Fri, 3 Apr 2026 13:53:41 +0200 Subject: [PATCH 8/8] Fix --- compiler/frontend/bs_ast_invariant.ml | 45 ++++++++++--------- compiler/frontend/bs_ast_invariant.mli | 4 +- compiler/frontend/ppx_entry.ml | 4 +- .../malformed_warning_attribute.resi.expected | 2 +- ..._warning_signature_attribute.resi.expected | 12 +++++ ...d_warning_structure_attribute.res.expected | 12 +++++ ...pwarning_signature_attribute.resi.expected | 11 +++++ ...ppwarning_structure_attribute.res.expected | 11 +++++ ..._warning_signature_attribute.resi.expected | 10 +++++ ...d_warning_structure_attribute.res.expected | 10 +++++ ...pwarning_signature_attribute.resi.expected | 9 ++++ ...ppwarning_structure_attribute.res.expected | 9 ++++ ...pwarning_signature_attribute.resi.expected | 2 +- ...malformed_warning_signature_attribute.resi | 4 ++ ..._malformed_warning_structure_attribute.res | 4 ++ .../nested_ppwarning_signature_attribute.resi | 4 ++ .../nested_ppwarning_structure_attribute.res | 4 ++ ...malformed_warning_signature_attribute.resi | 2 + ..._malformed_warning_structure_attribute.res | 2 + ...leading_ppwarning_signature_attribute.resi | 2 + ...nleading_ppwarning_structure_attribute.res | 2 + 21 files changed, 137 insertions(+), 28 deletions(-) create mode 100644 tests/build_tests/super_errors/expected/nested_malformed_warning_signature_attribute.resi.expected create mode 100644 tests/build_tests/super_errors/expected/nested_malformed_warning_structure_attribute.res.expected create mode 100644 tests/build_tests/super_errors/expected/nested_ppwarning_signature_attribute.resi.expected create mode 100644 tests/build_tests/super_errors/expected/nested_ppwarning_structure_attribute.res.expected create mode 100644 tests/build_tests/super_errors/expected/nonleading_malformed_warning_signature_attribute.resi.expected create mode 100644 tests/build_tests/super_errors/expected/nonleading_malformed_warning_structure_attribute.res.expected create mode 100644 tests/build_tests/super_errors/expected/nonleading_ppwarning_signature_attribute.resi.expected create mode 100644 tests/build_tests/super_errors/expected/nonleading_ppwarning_structure_attribute.res.expected create mode 100644 tests/build_tests/super_errors/fixtures/nested_malformed_warning_signature_attribute.resi create mode 100644 tests/build_tests/super_errors/fixtures/nested_malformed_warning_structure_attribute.res create mode 100644 tests/build_tests/super_errors/fixtures/nested_ppwarning_signature_attribute.resi create mode 100644 tests/build_tests/super_errors/fixtures/nested_ppwarning_structure_attribute.res create mode 100644 tests/build_tests/super_errors/fixtures/nonleading_malformed_warning_signature_attribute.resi create mode 100644 tests/build_tests/super_errors/fixtures/nonleading_malformed_warning_structure_attribute.res create mode 100644 tests/build_tests/super_errors/fixtures/nonleading_ppwarning_signature_attribute.resi create mode 100644 tests/build_tests/super_errors/fixtures/nonleading_ppwarning_structure_attribute.res diff --git a/compiler/frontend/bs_ast_invariant.ml b/compiler/frontend/bs_ast_invariant.ml index cbe5a4432ee..48ccb422a16 100644 --- a/compiler/frontend/bs_ast_invariant.ml +++ b/compiler/frontend/bs_ast_invariant.ml @@ -50,6 +50,21 @@ type iterator = Ast_iterator.iterator let super = Ast_iterator.default_iterator +let warning_attribute_iterator = + let structure_item self (structure_item : Parsetree.structure_item) = + (match structure_item.pstr_desc with + | Pstr_attribute attr -> Builtin_attributes.warning_attribute attr + | _ -> ()); + super.structure_item self structure_item + in + let signature_item self (signature_item : Parsetree.signature_item) = + (match signature_item.psig_desc with + | Psig_attribute attr -> Builtin_attributes.warning_attribute attr + | _ -> ()); + super.signature_item self signature_item + in + {super with structure_item; signature_item} + let check_constant loc (const : Parsetree.constant) = match const with | Pconst_string (_, Some s) -> @@ -148,28 +163,14 @@ let emit_external_warnings : iterator = | _ -> super.pat self pat); } -let rec iter_warnings_on_stru (stru : Parsetree.structure) = - match stru with - | [] -> () - | head :: rest -> ( - match head.pstr_desc with - | Pstr_attribute attr -> - Builtin_attributes.warning_attribute attr; - iter_warnings_on_stru rest - | _ -> ()) +let iter_warnings_on_structure (structure : Parsetree.structure) = + warning_attribute_iterator.structure warning_attribute_iterator structure -let rec iter_warnings_on_sigi (stru : Parsetree.signature) = - match stru with - | [] -> () - | head :: rest -> ( - match head.psig_desc with - | Psig_attribute attr -> - Builtin_attributes.warning_attribute attr; - iter_warnings_on_sigi rest - | _ -> ()) +let iter_warnings_on_signature (signature : Parsetree.signature) = + warning_attribute_iterator.signature warning_attribute_iterator signature -let emit_external_warnings_on_structure (stru : Parsetree.structure) = - emit_external_warnings.structure emit_external_warnings stru +let emit_external_warnings_on_structure (structure : Parsetree.structure) = + emit_external_warnings.structure emit_external_warnings structure -let emit_external_warnings_on_signature (sigi : Parsetree.signature) = - emit_external_warnings.signature emit_external_warnings sigi +let emit_external_warnings_on_signature (signature : Parsetree.signature) = + emit_external_warnings.signature emit_external_warnings signature diff --git a/compiler/frontend/bs_ast_invariant.mli b/compiler/frontend/bs_ast_invariant.mli index b3b580ebfa5..667d6b863d2 100644 --- a/compiler/frontend/bs_ast_invariant.mli +++ b/compiler/frontend/bs_ast_invariant.mli @@ -30,9 +30,9 @@ type iterator = Ast_iterator.iterator val warn_discarded_unused_attributes : Parsetree.attributes -> unit (** Ast invariant checking for detecting errors *) -val iter_warnings_on_stru : Parsetree.structure -> unit +val iter_warnings_on_structure : Parsetree.structure -> unit -val iter_warnings_on_sigi : Parsetree.signature -> unit +val iter_warnings_on_signature : Parsetree.signature -> unit val emit_external_warnings_on_structure : Parsetree.structure -> unit diff --git a/compiler/frontend/ppx_entry.ml b/compiler/frontend/ppx_entry.ml index e86949064f7..4afeaf2d442 100644 --- a/compiler/frontend/ppx_entry.ml +++ b/compiler/frontend/ppx_entry.ml @@ -25,7 +25,7 @@ let unsafe_mapper = Bs_builtin_ppx.mapper let rewrite_signature (ast : Parsetree.signature) : Parsetree.signature = - Bs_ast_invariant.iter_warnings_on_sigi ast; + Bs_ast_invariant.iter_warnings_on_signature ast; Ast_config.process_sig ast; let ast = match !Js_config.jsx_version with @@ -44,7 +44,7 @@ let rewrite_signature (ast : Parsetree.signature) : Parsetree.signature = result let rewrite_implementation (ast : Parsetree.structure) : Parsetree.structure = - Bs_ast_invariant.iter_warnings_on_stru ast; + Bs_ast_invariant.iter_warnings_on_structure ast; Ast_config.process_str ast; let ast = match !Js_config.jsx_version with diff --git a/tests/build_tests/super_errors/expected/malformed_warning_attribute.resi.expected b/tests/build_tests/super_errors/expected/malformed_warning_attribute.resi.expected index 489b10a0603..d64681c8120 100644 --- a/tests/build_tests/super_errors/expected/malformed_warning_attribute.resi.expected +++ b/tests/build_tests/super_errors/expected/malformed_warning_attribute.resi.expected @@ -7,4 +7,4 @@ 3 │ let x: int illegal payload for attribute 'warning'. -A single string literal is expected +A single string literal is expected \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/nested_malformed_warning_signature_attribute.resi.expected b/tests/build_tests/super_errors/expected/nested_malformed_warning_signature_attribute.resi.expected new file mode 100644 index 00000000000..721f234b4be --- /dev/null +++ b/tests/build_tests/super_errors/expected/nested_malformed_warning_signature_attribute.resi.expected @@ -0,0 +1,12 @@ + + Warning number 47 + /.../fixtures/nested_malformed_warning_signature_attribute.resi:3:3-11 + + 1 │ module M: { + 2 │ let y: int + 3 │ @@warning(123) + 4 │ } + 5 │ + + illegal payload for attribute 'warning'. +A single string literal is expected \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/nested_malformed_warning_structure_attribute.res.expected b/tests/build_tests/super_errors/expected/nested_malformed_warning_structure_attribute.res.expected new file mode 100644 index 00000000000..0d60d9eb9bd --- /dev/null +++ b/tests/build_tests/super_errors/expected/nested_malformed_warning_structure_attribute.res.expected @@ -0,0 +1,12 @@ + + Warning number 47 + /.../fixtures/nested_malformed_warning_structure_attribute.res:3:3-11 + + 1 │ module M = { + 2 │ let y = 1 + 3 │ @@warning(123) + 4 │ } + 5 │ + + illegal payload for attribute 'warning'. +A single string literal is expected \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/nested_ppwarning_signature_attribute.resi.expected b/tests/build_tests/super_errors/expected/nested_ppwarning_signature_attribute.resi.expected new file mode 100644 index 00000000000..dc8bd5968d4 --- /dev/null +++ b/tests/build_tests/super_errors/expected/nested_ppwarning_signature_attribute.resi.expected @@ -0,0 +1,11 @@ + + Warning number 22 + /.../fixtures/nested_ppwarning_signature_attribute.resi:3:15-21 + + 1 │ module M: { + 2 │ let y: int + 3 │ @@ppwarning("hello") + 4 │ } + 5 │ + + hello \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/nested_ppwarning_structure_attribute.res.expected b/tests/build_tests/super_errors/expected/nested_ppwarning_structure_attribute.res.expected new file mode 100644 index 00000000000..67a8db2b4aa --- /dev/null +++ b/tests/build_tests/super_errors/expected/nested_ppwarning_structure_attribute.res.expected @@ -0,0 +1,11 @@ + + Warning number 22 + /.../fixtures/nested_ppwarning_structure_attribute.res:3:15-21 + + 1 │ module M = { + 2 │ let y = 1 + 3 │ @@ppwarning("hello") + 4 │ } + 5 │ + + hello \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/nonleading_malformed_warning_signature_attribute.resi.expected b/tests/build_tests/super_errors/expected/nonleading_malformed_warning_signature_attribute.resi.expected new file mode 100644 index 00000000000..a9b354f6d60 --- /dev/null +++ b/tests/build_tests/super_errors/expected/nonleading_malformed_warning_signature_attribute.resi.expected @@ -0,0 +1,10 @@ + + Warning number 47 + /.../fixtures/nonleading_malformed_warning_signature_attribute.resi:2:1-9 + + 1 │ let y: int + 2 │ @@warning(123) + 3 │ + + illegal payload for attribute 'warning'. +A single string literal is expected \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/nonleading_malformed_warning_structure_attribute.res.expected b/tests/build_tests/super_errors/expected/nonleading_malformed_warning_structure_attribute.res.expected new file mode 100644 index 00000000000..78ab2f89bc1 --- /dev/null +++ b/tests/build_tests/super_errors/expected/nonleading_malformed_warning_structure_attribute.res.expected @@ -0,0 +1,10 @@ + + Warning number 47 + /.../fixtures/nonleading_malformed_warning_structure_attribute.res:2:1-9 + + 1 │ let y = 1 + 2 │ @@warning(123) + 3 │ + + illegal payload for attribute 'warning'. +A single string literal is expected \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/nonleading_ppwarning_signature_attribute.resi.expected b/tests/build_tests/super_errors/expected/nonleading_ppwarning_signature_attribute.resi.expected new file mode 100644 index 00000000000..1a29e2be231 --- /dev/null +++ b/tests/build_tests/super_errors/expected/nonleading_ppwarning_signature_attribute.resi.expected @@ -0,0 +1,9 @@ + + Warning number 22 + /.../fixtures/nonleading_ppwarning_signature_attribute.resi:2:13-19 + + 1 │ let y: int + 2 │ @@ppwarning("hello") + 3 │ + + hello \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/nonleading_ppwarning_structure_attribute.res.expected b/tests/build_tests/super_errors/expected/nonleading_ppwarning_structure_attribute.res.expected new file mode 100644 index 00000000000..0c5b2df957f --- /dev/null +++ b/tests/build_tests/super_errors/expected/nonleading_ppwarning_structure_attribute.res.expected @@ -0,0 +1,9 @@ + + Warning number 22 + /.../fixtures/nonleading_ppwarning_structure_attribute.res:2:13-19 + + 1 │ let y = 1 + 2 │ @@ppwarning("hello") + 3 │ + + hello \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/ppwarning_signature_attribute.resi.expected b/tests/build_tests/super_errors/expected/ppwarning_signature_attribute.resi.expected index ca0612eab85..a7a9a73084f 100644 --- a/tests/build_tests/super_errors/expected/ppwarning_signature_attribute.resi.expected +++ b/tests/build_tests/super_errors/expected/ppwarning_signature_attribute.resi.expected @@ -6,4 +6,4 @@ 2 │ 3 │ let x: int - hello + hello \ No newline at end of file diff --git a/tests/build_tests/super_errors/fixtures/nested_malformed_warning_signature_attribute.resi b/tests/build_tests/super_errors/fixtures/nested_malformed_warning_signature_attribute.resi new file mode 100644 index 00000000000..f5eae9c9198 --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/nested_malformed_warning_signature_attribute.resi @@ -0,0 +1,4 @@ +module M: { + let y: int + @@warning(123) +} diff --git a/tests/build_tests/super_errors/fixtures/nested_malformed_warning_structure_attribute.res b/tests/build_tests/super_errors/fixtures/nested_malformed_warning_structure_attribute.res new file mode 100644 index 00000000000..a6fe5be712a --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/nested_malformed_warning_structure_attribute.res @@ -0,0 +1,4 @@ +module M = { + let y = 1 + @@warning(123) +} diff --git a/tests/build_tests/super_errors/fixtures/nested_ppwarning_signature_attribute.resi b/tests/build_tests/super_errors/fixtures/nested_ppwarning_signature_attribute.resi new file mode 100644 index 00000000000..b2b9041016a --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/nested_ppwarning_signature_attribute.resi @@ -0,0 +1,4 @@ +module M: { + let y: int + @@ppwarning("hello") +} diff --git a/tests/build_tests/super_errors/fixtures/nested_ppwarning_structure_attribute.res b/tests/build_tests/super_errors/fixtures/nested_ppwarning_structure_attribute.res new file mode 100644 index 00000000000..fb87c43da8c --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/nested_ppwarning_structure_attribute.res @@ -0,0 +1,4 @@ +module M = { + let y = 1 + @@ppwarning("hello") +} diff --git a/tests/build_tests/super_errors/fixtures/nonleading_malformed_warning_signature_attribute.resi b/tests/build_tests/super_errors/fixtures/nonleading_malformed_warning_signature_attribute.resi new file mode 100644 index 00000000000..65cc613f38a --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/nonleading_malformed_warning_signature_attribute.resi @@ -0,0 +1,2 @@ +let y: int +@@warning(123) diff --git a/tests/build_tests/super_errors/fixtures/nonleading_malformed_warning_structure_attribute.res b/tests/build_tests/super_errors/fixtures/nonleading_malformed_warning_structure_attribute.res new file mode 100644 index 00000000000..fa0d1033a8e --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/nonleading_malformed_warning_structure_attribute.res @@ -0,0 +1,2 @@ +let y = 1 +@@warning(123) diff --git a/tests/build_tests/super_errors/fixtures/nonleading_ppwarning_signature_attribute.resi b/tests/build_tests/super_errors/fixtures/nonleading_ppwarning_signature_attribute.resi new file mode 100644 index 00000000000..b110d72c831 --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/nonleading_ppwarning_signature_attribute.resi @@ -0,0 +1,2 @@ +let y: int +@@ppwarning("hello") diff --git a/tests/build_tests/super_errors/fixtures/nonleading_ppwarning_structure_attribute.res b/tests/build_tests/super_errors/fixtures/nonleading_ppwarning_structure_attribute.res new file mode 100644 index 00000000000..35c88da5634 --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/nonleading_ppwarning_structure_attribute.res @@ -0,0 +1,2 @@ +let y = 1 +@@ppwarning("hello")