diff --git a/CHANGELOG.md b/CHANGELOG.md index 4309a17924a..83c31f3c361 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,6 +82,7 @@ #### :house: Internal +- Remove OCaml leftovers: unused warning numbers, the `Record_float_unused` representation, the `ns.braces` attribute name and unused `Ast_helper` functions. https://github.com/rescript-lang/rescript/pull/8805 - Remove the S-expression parsetree printer (`res_parser -print sexp`). https://github.com/rescript-lang/rescript/pull/8803 - Use one set of OCaml warning flags for the whole repository, including the editor analysis and tools. https://github.com/rescript-lang/rescript/pull/8796 - Remove the unused `Packed` and `Partial_class_expr` constructors from the `.cmt` format and bump its magic number. https://github.com/rescript-lang/rescript/pull/8793 diff --git a/compiler/ext/bsc_warnings.ml b/compiler/ext/bsc_warnings.ml index 83ec4124273..955f9da9be2 100644 --- a/compiler/ext/bsc_warnings.ml +++ b/compiler/ext/bsc_warnings.ml @@ -41,12 +41,10 @@ type b = A | B | C ]} - - 50 Unexpected documentation comment. - - 102 Bs_polymorphic_comparison. *) (* If you change this, don't forget to adapt docs/docson/build-schema.json as well. *) -let defaults_w = "+a-4-9-20-41-50-102" +let defaults_w = "+a-4-9-20-41-102" -let defaults_warn_error = "-a+5+6+101+109" +let defaults_warn_error = "-a+5+101+109" (*TODO: add +10*) diff --git a/compiler/ext/config.ml b/compiler/ext/config.ml index 7644a6cb98d..432d1e3b25a 100644 --- a/compiler/ext/config.ml +++ b/compiler/ext/config.ml @@ -1,4 +1,4 @@ -let cmi_magic_number = "Caml1999I035" +let cmi_magic_number = "Caml1999I036" (* Magic numbers for marshaled values of the *current* parsetree, whose layout changes across compiler versions. *) @@ -13,6 +13,6 @@ and ast0_impl_magic_number = "Caml1999M022" and ast0_intf_magic_number = "Caml1999N022" -and cmt_magic_number = "Caml1999T042" +and cmt_magic_number = "Caml1999T043" let load_path = ref ([] : string list) diff --git a/compiler/ext/warnings.ml b/compiler/ext/warnings.ml index 64fd263327b..3bb428d2683 100644 --- a/compiler/ext/warnings.ml +++ b/compiler/ext/warnings.ml @@ -140,7 +140,7 @@ let letter_all = let letter = function | 'a' -> letter_all | 'b' -> [] - | 'c' -> [1; 2] + | 'c' -> [] | 'd' -> [3] | 'e' -> [4] | 'f' -> [5] @@ -148,20 +148,20 @@ let letter = function | 'h' -> [] | 'i' -> [] | 'j' -> [] - | 'k' -> [32; 33; 34; 35; 36; 37; 38; 39] - | 'l' -> [6] - | 'm' -> [7] + | 'k' -> [32; 33; 34; 35; 37; 38; 39] + | 'l' -> [] + | 'm' -> [] | 'n' -> [] | 'o' -> [] | 'p' -> [8] | 'q' -> [] | 'r' -> [9] - | 's' -> [10] + | 's' -> [] | 't' -> [] | 'u' -> [11; 12] - | 'v' -> [13] + | 'v' -> [] | 'w' -> [] - | 'x' -> [14; 15; 16; 17; 18; 19; 20; 21; 22; 23; 24; 30] + | 'x' -> [20; 21; 22; 23; 30] | 'y' -> [26] | 'z' -> [27] | _ -> assert false @@ -505,14 +505,10 @@ let descriptions = (9, "Missing fields in a record pattern."); (11, "Redundant case in a pattern matching (unused match case)."); (12, "Redundant sub-pattern in a pattern-matching."); - (17, "Undeclared virtual method."); - (18, "Non-principal type."); - (19, "Type without principality."); (20, "Unused function argument."); (21, "Non-returning statement."); (22, "Preprocessor warning."); (23, "Useless record \"with\" clause."); - (25, "Deprecated: now part of warning 8."); ( 26, "Suspicious unused variable: unused variable that is bound\n\ \ with \"let\" or \"as\", and doesn't start with an underscore (\"_\")\n\ @@ -525,12 +521,10 @@ let descriptions = ( 30, "Two labels or constructors of the same name are defined in two\n\ \ mutually recursive types." ); - (31, "A module is linked twice in the same executable."); (32, "Unused value declaration."); (33, "Unused open statement."); (34, "Unused type declaration."); (35, "Unused for-loop index."); - (36, "Unused ancestor variable."); (37, "Unused constructor."); (38, "Unused extension constructor."); (39, "Unused rec flag."); @@ -538,16 +532,13 @@ let descriptions = (43, "Nonoptional label applied as optional."); (44, "Open statement shadows an already defined identifier."); (45, "Open statement shadows an already defined label or constructor."); - (46, "Error in environment variable."); (47, "Illegal attribute payload."); (49, "Absent cmi file when looking up module alias."); (52, "Fragile constant pattern."); (53, "Attribute cannot appear in this context"); (54, "Attribute used more than once on an expression"); - (55, "Inlining impossible"); (56, "Unreachable case in a pattern-matching (based on type information)."); (57, "Ambiguous or-pattern variables under guard"); - (59, "Assignment to non-mutable value"); (60, "Unused module declaration"); (62, "Type constraint on GADT type declaration"); (101, "Unused bs attributes"); diff --git a/compiler/gentype/translate_type_declarations.ml b/compiler/gentype/translate_type_declarations.ml index ea6052600cc..c7dfb2f69f7 100644 --- a/compiler/gentype/translate_type_declarations.ml +++ b/compiler/gentype/translate_type_declarations.ml @@ -230,7 +230,6 @@ let traslate_declaration_kind ~config ~loc ~output_file_relative ~resolver match representation with | Record_unboxed _ -> true | Record_regular | Record_inlined _ | Record_extension -> false - | Record_float_unused -> assert false in let {Translate_type_expr_from_types.dependencies; type_} = label_declarations |> translate_label_declarations ~unboxed diff --git a/compiler/ml/ast_helper.ml b/compiler/ml/ast_helper.ml index 43fd072646e..162c6753f7e 100644 --- a/compiler/ml/ast_helper.ml +++ b/compiler/ml/ast_helper.ml @@ -29,12 +29,6 @@ let default_loc = ref Location.none module Const = struct let integer ?suffix i = Pconst_integer (i, suffix) let int ?suffix i = integer ?suffix (string_of_int i) - let int32 ?(suffix = 'l') i = integer ~suffix (Int32.to_string i) - let int64 ?(suffix = 'L') i = integer ~suffix (Int64.to_string i) - let float ?suffix f = Pconst_float (f, suffix) - let char c = - let semantic = Char.code c in - Pconst_char {source = String_literal.encode_char_source semantic; semantic} let string semantic = Pconst_string (String_literal.string_from_semantic semantic) end @@ -42,7 +36,6 @@ end module Typ = struct let mk ?(loc = !default_loc) ?(attrs = []) d = {ptyp_desc = d; ptyp_loc = loc; ptyp_attributes = attrs} - let attr d a = {d with ptyp_attributes = d.ptyp_attributes @ [a]} let any ?loc ?attrs () = mk ?loc ?attrs Ptyp_any let var ?loc ?attrs a = mk ?loc ?attrs (Ptyp_var a) @@ -127,7 +120,6 @@ end module Pat = struct let mk ?(loc = !default_loc) ?(attrs = []) d = {ppat_desc = d; ppat_loc = loc; ppat_attributes = attrs} - let attr d a = {d with ppat_attributes = d.ppat_attributes @ [a]} let any ?loc ?attrs () = mk ?loc ?attrs Ppat_any let var ?loc ?attrs a = mk ?loc ?attrs (Ppat_var a) @@ -152,7 +144,6 @@ end module Exp = struct let mk ?(loc = !default_loc) ?(attrs = []) d = {pexp_desc = d; pexp_loc = loc; pexp_attributes = attrs} - let attr d a = {d with pexp_attributes = d.pexp_attributes @ [a]} let braces ?(attrs = []) ~braces_loc e = mk ~loc:e.pexp_loc ~attrs (Pexp_braces {expr = e; braces_loc}) @@ -267,7 +258,6 @@ end module Mty = struct let mk ?(loc = !default_loc) ?(attrs = []) d = {pmty_desc = d; pmty_loc = loc; pmty_attributes = attrs} - let attr d a = {d with pmty_attributes = d.pmty_attributes @ [a]} let ident ?loc ?attrs a = mk ?loc ?attrs (Pmty_ident a) let alias ?loc ?attrs a = mk ?loc ?attrs (Pmty_alias a) @@ -281,7 +271,6 @@ end module Mod = struct let mk ?(loc = !default_loc) ?(attrs = []) d = {pmod_desc = d; pmod_loc = loc; pmod_attributes = attrs} - let attr d a = {d with pmod_attributes = d.pmod_attributes @ [a]} let ident ?loc ?attrs x = mk ?loc ?attrs (Pmod_ident x) let structure ?loc ?attrs x = mk ?loc ?attrs (Pmod_structure x) @@ -562,23 +551,6 @@ module Te = struct pext_loc = loc; pext_attributes = attrs; } - - let decl ?(loc = !default_loc) ?(attrs = []) ?(args = Pcstr_tuple []) ?res - name = - { - pext_name = name; - pext_kind = Pext_decl (args, res); - pext_loc = loc; - pext_attributes = attrs; - } - - let rebind ?(loc = !default_loc) ?(attrs = []) name lid = - { - pext_name = name; - pext_kind = Pext_rebind lid; - pext_loc = loc; - pext_attributes = attrs; - } end module Jsx = struct diff --git a/compiler/ml/ast_helper.mli b/compiler/ml/ast_helper.mli index bf1dad721a7..19d502945e1 100644 --- a/compiler/ml/ast_helper.mli +++ b/compiler/ml/ast_helper.mli @@ -28,13 +28,9 @@ type attrs = attribute list (** {1 Constants} *) module Const : sig - val char : char -> constant val string : string -> constant val integer : ?suffix:char -> string -> constant val int : ?suffix:char -> int -> constant - val int32 : ?suffix:char -> int32 -> constant - val int64 : ?suffix:char -> int64 -> constant - val float : ?suffix:char -> string -> constant end (** {1 Core language} *) @@ -42,7 +38,6 @@ end (** Type expressions *) module Typ : sig val mk : ?loc:loc -> ?attrs:attrs -> core_type_desc -> core_type - val attr : core_type -> attribute -> core_type val any : ?loc:loc -> ?attrs:attrs -> unit -> core_type val var : ?loc:loc -> ?attrs:attrs -> string -> core_type @@ -81,7 +76,6 @@ end (** Patterns *) module Pat : sig val mk : ?loc:loc -> ?attrs:attrs -> pattern_desc -> pattern - val attr : pattern -> attribute -> pattern val any : ?loc:loc -> ?attrs:attrs -> unit -> pattern val var : ?loc:loc -> ?attrs:attrs -> str -> pattern @@ -117,7 +111,6 @@ end (** Expressions *) module Exp : sig val mk : ?loc:loc -> ?attrs:attrs -> expression_desc -> expression - val attr : expression -> attribute -> expression val braces : ?attrs:attrs -> braces_loc:loc -> expression -> expression val ident : ?loc:loc -> ?attrs:attrs -> lid -> expression @@ -358,15 +351,6 @@ module Te : sig str -> extension_constructor_kind -> extension_constructor - - val decl : - ?loc:loc -> - ?attrs:attrs -> - ?args:constructor_arguments -> - ?res:core_type -> - str -> - extension_constructor - val rebind : ?loc:loc -> ?attrs:attrs -> str -> lid -> extension_constructor end module Jsx : sig @@ -379,7 +363,6 @@ end (** Module type expressions *) module Mty : sig val mk : ?loc:loc -> ?attrs:attrs -> module_type_desc -> module_type - val attr : module_type -> attribute -> module_type val ident : ?loc:loc -> ?attrs:attrs -> lid -> module_type val alias : ?loc:loc -> ?attrs:attrs -> lid -> module_type @@ -404,7 +387,6 @@ end (** Module expressions *) module Mod : sig val mk : ?loc:loc -> ?attrs:attrs -> module_expr_desc -> module_expr - val attr : module_expr -> attribute -> module_expr val ident : ?loc:loc -> ?attrs:attrs -> lid -> module_expr val structure : ?loc:loc -> ?attrs:attrs -> structure -> module_expr diff --git a/compiler/ml/ast_mapper_from0.ml b/compiler/ml/ast_mapper_from0.ml index d44ea4d7d07..810a42dcdb8 100644 --- a/compiler/ml/ast_mapper_from0.ml +++ b/compiler/ml/ast_mapper_from0.ml @@ -745,8 +745,7 @@ module E = struct in let first_wrapper = let rec find = function - | ({txt = "res.braces" | "ns.braces"; loc}, _) :: _ -> - Some (`Braces loc) + | ({txt = "res.braces"; loc}, _) :: _ -> Some (`Braces loc) | ({txt = "res.await"}, _) :: _ -> Some `Await | _ :: rest -> find rest | [] -> None @@ -760,7 +759,7 @@ module E = struct | _ -> false -> let outer_attrs0, braces_loc, inner_attrs0 = let rec split acc = function - | ({Location.txt = "res.braces" | "ns.braces"; loc}, _) :: rest -> + | ({Location.txt = "res.braces"; loc}, _) :: rest -> (List.rev acc, loc, rest) | a :: rest -> split (a :: acc) rest | [] -> assert false diff --git a/compiler/ml/matching.ml b/compiler/ml/matching.ml index dfabf676e2b..ecf81aa544a 100644 --- a/compiler/ml/matching.ml +++ b/compiler/ml/matching.ml @@ -1488,7 +1488,6 @@ let make_record_matching loc all_labels def = function let lbl = all_labels.(pos) in let access = match lbl.lbl_repres with - | Record_float_unused -> assert false | Record_regular -> prim ~primitive: diff --git a/compiler/ml/printtyped.ml b/compiler/ml/printtyped.ml index 73eb6f36bf9..fd0c8e58bd1 100644 --- a/compiler/ml/printtyped.ml +++ b/compiler/ml/printtyped.ml @@ -127,7 +127,6 @@ let record_representation i ppf = let open Types in function | Record_regular -> line i ppf "Record_regular\n" - | Record_float_unused -> assert false | Record_unboxed b -> line i ppf "Record_unboxed %b\n" b | Record_inlined {name} -> line i ppf "Record_inlined %s\n" name | Record_extension -> line i ppf "Record_extension\n" diff --git a/compiler/ml/rec_check.ml b/compiler/ml/rec_check.ml index 30f063e46db..b2e7f2c9244 100644 --- a/compiler/ml/rec_check.ml +++ b/compiler/ml/rec_check.ml @@ -292,7 +292,6 @@ let rec expression : Env.env -> Typedtree.expression -> Use.t = let use = match rep with | Record_unboxed _ -> fun x -> x - | Record_float_unused -> assert false | Record_regular | Record_inlined _ | Record_extension -> Use.guard in let field env = function diff --git a/compiler/ml/translcore.ml b/compiler/ml/translcore.ml index 7ba2099d2d6..a5897de7876 100644 --- a/compiler/ml/translcore.ml +++ b/compiler/ml/translcore.ml @@ -1411,7 +1411,6 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.t = | Texp_field (arg, _, lbl) -> ( let targ = transl_exp arg in match lbl.lbl_repres with - | Record_float_unused -> assert false | Record_regular -> prim ~primitive: @@ -1432,7 +1431,6 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.t = | Texp_setfield (arg, _, lbl, newval) -> let access = match lbl.lbl_repres with - | Record_float_unused -> assert false | Record_regular -> Psetfield (lbl.lbl_pos, Lambda.fld_record_set lbl.lbl_runtime_name) | Record_inlined _ -> @@ -1768,7 +1766,6 @@ and transl_record loc env fields repres opt_init_expr = | Kept _ -> let access = match repres with - | Record_float_unused -> assert false | Record_regular -> Pfield (i, Lambda.fld_record lbl.lbl_runtime_name) | Record_inlined _ -> @@ -1793,7 +1790,6 @@ and transl_record loc env fields repres opt_init_expr = if mut = Mutable then raise Not_constant; let cl = List.map extract_constant ll in match repres with - | Record_float_unused -> assert false | Record_regular -> const (Const_block (Lambda.blk_record (field_shape ()) mut, cl)) | Record_inlined {name; representation} -> @@ -1823,7 +1819,6 @@ and transl_record loc env fields repres opt_init_expr = prim ~primitive:(Pmakeblock (Lambda.blk_record (field_shape ()) mut)) ~args:ll loc - | Record_float_unused -> assert false | Record_inlined {name; representation} -> let runtime = match Variant_runtime.representation representation with @@ -1870,7 +1865,6 @@ and transl_record loc env fields repres opt_init_expr = | Overridden (_lid, expr) -> let upd = match repres with - | Record_float_unused -> assert false | Record_regular -> Psetfield (lbl.lbl_pos, Lambda.fld_record_set lbl.lbl_runtime_name) | Record_inlined _ -> diff --git a/compiler/ml/types.ml b/compiler/ml/types.ml index 94147e90342..9808899d8fa 100644 --- a/compiler/ml/types.ml +++ b/compiler/ml/types.ml @@ -154,7 +154,6 @@ and type_kind = and record_representation = | Record_regular (* All fields are boxed / tagged *) - | Record_float_unused (* Was: all fields are floats. Now: unused *) | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) | Record_inlined of (* Inlined record *) @@ -325,7 +324,6 @@ type label_description = { let same_record_representation x y = match x with | Record_regular -> y = Record_regular - | Record_float_unused -> y = Record_float_unused | Record_inlined {name} -> ( match y with | Record_inlined y -> name = y.name diff --git a/compiler/ml/types.mli b/compiler/ml/types.mli index e8ae34ce2b3..a40961b5d61 100644 --- a/compiler/ml/types.mli +++ b/compiler/ml/types.mli @@ -251,7 +251,6 @@ and type_kind = and record_representation = | Record_regular (* All fields are boxed / tagged *) - | Record_float_unused (* Was: all fields are floats. Now: unused *) | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) | Record_inlined of (* Inlined record *) diff --git a/docs/docson/build-schema.json b/docs/docson/build-schema.json index 2c3e1b30fec..9fe363ce4a5 100644 --- a/docs/docson/build-schema.json +++ b/docs/docson/build-schema.json @@ -446,7 +446,7 @@ "properties": { "number": { "type": "string", - "description": "Default: \"+a-4-9-20-41-50-102\". Go [here](https://rescript-lang.org/docs/manual/latest/warning-numbers) for the meanings of the warning flags" + "description": "Default: \"+a-4-9-20-41-102\". Go [here](https://rescript-lang.org/docs/manual/latest/warning-numbers) for the meanings of the warning flags" }, "error": { "oneOf": [ diff --git a/packages/dev-playground/src/CompilerApi.res b/packages/dev-playground/src/CompilerApi.res index 361204c69e6..1715921e14d 100644 --- a/packages/dev-playground/src/CompilerApi.res +++ b/packages/dev-playground/src/CompilerApi.res @@ -89,7 +89,7 @@ type normalizedConfig = { sourceMapRoot: string, } -let defaultWarnFlags = "+a-4-9-20-40-41-42-50-61-102-109" +let defaultWarnFlags = "+a-4-9-20-41-102-109" let defaultCompilerVersion = Env.viteDefaultCompilerVersion->Option.getOr("local") diff --git a/tests/ERROR_VARIANTS.md b/tests/ERROR_VARIANTS.md index 4449cd3a240..e0e3e7e3efc 100644 --- a/tests/ERROR_VARIANTS.md +++ b/tests/ERROR_VARIANTS.md @@ -551,9 +551,9 @@ PPX/malformed ASTs, or test helper APIs, were retained and reclassified. ## Warnings Warnings are declared in [`compiler/ext/warnings.ml`](../compiler/ext/warnings.ml). -The default warning set is `+a-4-9-20-41-50-102` +The default warning set is `+a-4-9-20-41-102` ([`compiler/ext/bsc_warnings.ml`](../compiler/ext/bsc_warnings.ml)), so -warnings 4, 9, 20, 41, 50, and 102 are disabled by default; the rest are +warnings 4, 9, 20, 41, and 102 are disabled by default; the rest are enabled. Fixtures use `-w +A` (everything on) so default-disabled warnings still fire.