From c60456bbb70a02cb69832a7b25a660632e16f2da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Thu, 1 May 2025 19:19:47 +0100 Subject: [PATCH 1/7] Remove warnings 40, 42 and 61 from the list of default warnings --- compiler/ext/bsc_warnings.ml | 2 +- docs/docson/build-schema.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/ext/bsc_warnings.ml b/compiler/ext/bsc_warnings.ml index 9769142843..fde8519441 100644 --- a/compiler/ext/bsc_warnings.ml +++ b/compiler/ext/bsc_warnings.ml @@ -70,7 +70,7 @@ - 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/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": [ From 5f3b4f738f1b0594ca8dc2deb9937cc85d92d903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Thu, 1 May 2025 19:20:07 +0100 Subject: [PATCH 2/7] Remove description for warning 61 as it no longer exists --- compiler/ext/warnings.ml | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/ext/warnings.ml b/compiler/ext/warnings.ml index 18207a3e13..b463d01ef8 100644 --- a/compiler/ext/warnings.ml +++ b/compiler/ext/warnings.ml @@ -647,7 +647,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)"); From 2fedde4a9b451a109261f74af33357304267c4b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Thu, 1 May 2025 19:20:58 +0100 Subject: [PATCH 3/7] Update descriptions of warnings in default list --- compiler/ext/bsc_warnings.ml | 40 ++++++++---------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/compiler/ext/bsc_warnings.ml b/compiler/ext/bsc_warnings.ml index fde8519441..83ec412427 100644 --- a/compiler/ext/bsc_warnings.ml +++ b/compiler/ext/bsc_warnings.ml @@ -22,52 +22,28 @@ * 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-41-50-102" From fb6711d2177c82c77e9c12c27b3143cf44e59038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Thu, 1 May 2025 19:24:27 +0100 Subject: [PATCH 4/7] Add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 7d8d526fde307e1d9090c0fcbab5a35f7abc1fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Thu, 1 May 2025 19:27:21 +0100 Subject: [PATCH 5/7] Remove descriptions for removed warnings 51 and 6 --- compiler/ext/warnings.ml | 2 -- 1 file changed, 2 deletions(-) diff --git a/compiler/ext/warnings.ml b/compiler/ext/warnings.ml index b463d01ef8..0925d73a13 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."); @@ -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"); From df89772b111351bdfc433a1fff535f892a25563a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Thu, 1 May 2025 19:30:13 +0100 Subject: [PATCH 6/7] s/OCaml/ReScript --- compiler/ext/warnings.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ext/warnings.ml b/compiler/ext/warnings.ml index 0925d73a13..70c07c6eaf 100644 --- a/compiler/ext/warnings.ml +++ b/compiler/ext/warnings.ml @@ -603,7 +603,7 @@ 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, From 5ec436504a48f4f982c34bcf12fec7e4f22bd327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Thu, 1 May 2025 19:33:55 +0100 Subject: [PATCH 7/7] Format --- compiler/ext/warnings.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/ext/warnings.ml b/compiler/ext/warnings.ml index 70c07c6eaf..fd3d506411 100644 --- a/compiler/ext/warnings.ml +++ b/compiler/ext/warnings.ml @@ -603,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 ReScript 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\