diff --git a/CHANGELOG.md b/CHANGELOG.md index bea380fc63..49ca37c678 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ #### :house: Internal - Better representation of JSX in AST. https://github.com/rescript-lang/rescript/pull/7286 +- Clean up default warnings. https://github.com/rescript-lang/rescript/pull/7413 #### :nail_care: Polish diff --git a/compiler/ext/bsc_warnings.ml b/compiler/ext/bsc_warnings.ml index 9769142843..83ec412427 100644 --- a/compiler/ext/bsc_warnings.ml +++ b/compiler/ext/bsc_warnings.ml @@ -22,55 +22,31 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(** - See the meanings of the warning codes here: https://caml.inria.fr/pub/docs/manual-ocaml/comp.html#sec281 - - - 30 Two labels or constructors of the same name are defined in two mutually recursive types. - - 40 Constructor or label name used out of scope. - - - 6 Label omitted in function application. - - 7 Method overridden. - - 9 Missing fields in a record pattern. (*Not always desired, in some cases need [@@@warning "+9"] *) - - 27 Innocuous unused variable: unused variable that is not bound with let nor as, and doesn’t start with an underscore (_) character. - - 29 Unescaped end-of-line in a string constant (non-portable code). - - 32 .. 39 Unused blabla - - 44 Open statement shadows an already defined identifier. - - 45 Open statement shadows an already defined label or constructor. - - 48 Implicit elimination of optional arguments. https://caml.inria.fr/mantis/view.php?id=6352 - - 101 (bsb-specific) unsafe polymorphic comparison. -*) - (* - The purpose of default warning set is to make it strict while - not annoy user too much + The purpose of the default warning set is to make it strict while not annoying the user too much. - -4 Fragile pattern matching: matching that will remain complete even if additional con- structors are added to one of the variant types matched. - We turn it off since common pattern + - 4 Fragile pattern matching: matching that will remain complete even if additional constructors are added to one of the variant types matched. + We turn it off since the following is a common pattern: {[ - match x with | A -> .. | _ -> false + switch x { | A => .. | _ => false } ]} - -9 Missing fields in a record pattern. - only in some special cases that we need all fields being listed + - 9 Missing fields in a record pattern. + Only in some special cases that we need all fields being listed - We encourage people to write code based on type based disambigution - 40,41,42 are enabled for compatiblity reasons - -40 Constructor or label name used out of scope - This is intentional, we should never warn it - 41 Ambiguous constructor or label name. It is turned off since it prevents such cases below: {[ - type a = A |B + type a = A | B type b = A | B | C ]} - - 42 Disambiguated constructor or label name (compatibility warning). - 50 Unexpected documentation comment. - - 102 Bs_polymorphic_comparison + - 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-40-41-42-50-61-102" +let defaults_w = "+a-4-9-20-41-50-102" let defaults_warn_error = "-a+5+6+101+109" (*TODO: add +10*) diff --git a/compiler/ext/warnings.ml b/compiler/ext/warnings.ml index 18207a3e13..fd3d506411 100644 --- a/compiler/ext/warnings.ml +++ b/compiler/ext/warnings.ml @@ -583,7 +583,6 @@ let descriptions = ( 5, "Partially applied function: expression whose result has function\n\ \ type and is ignored." ); - (6, "Label omitted in function application."); (7, "Method overridden."); (8, "Partial match: missing cases in pattern-matching."); (9, "Missing fields in a record pattern."); @@ -604,8 +603,8 @@ let descriptions = (22, "Preprocessor warning."); (23, "Useless record \"with\" clause."); ( 24, - "Bad module name: the source file name is not a valid OCaml module name." - ); + "Bad module name: the source file name is not a valid ReScript module \ + name." ); (25, "Deprecated: now part of warning 8."); ( 26, "Suspicious unused variable: unused variable that is bound\n\ @@ -638,7 +637,6 @@ let descriptions = (48, "Implicit elimination of optional arguments."); (49, "Absent cmi file when looking up module alias."); (50, "Unexpected documentation comment."); - (51, "Warning on non-tail calls if @tailcall present."); (52, "Fragile constant pattern."); (53, "Attribute cannot appear in this context"); (54, "Attribute used more than once on an expression"); @@ -647,7 +645,6 @@ let descriptions = (57, "Ambiguous or-pattern variables under guard"); (59, "Assignment to non-mutable value"); (60, "Unused module declaration"); - (61, "Unboxable type in primitive declaration"); (62, "Type constraint on GADT type declaration"); (101, "Unused bs attributes"); (102, "Polymorphic comparison introduced (maybe unsafe)"); diff --git a/docs/docson/build-schema.json b/docs/docson/build-schema.json index 7d7432f834..9c5cc6ee53 100644 --- a/docs/docson/build-schema.json +++ b/docs/docson/build-schema.json @@ -440,7 +440,7 @@ "properties": { "number": { "type": "string", - "description": "Default: \"+a-4-9-20-40-41-42-50-61-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-50-102\". Go [here](https://rescript-lang.org/docs/manual/latest/warning-numbers) for the meanings of the warning flags" }, "error": { "oneOf": [