diff --git a/jscomp/build_tests/super_errors/expected/unused_variable.res.expected b/jscomp/build_tests/super_errors/expected/unused_variable.res.expected new file mode 100644 index 0000000000..dc6dc0adb4 --- /dev/null +++ b/jscomp/build_tests/super_errors/expected/unused_variable.res.expected @@ -0,0 +1,14 @@ + + Warning number 26 + /.../fixtures/unused_variable.res:2:7 + + 1 │ let x = { + 2 │ let f = 12 + 3 │ 13 + 4 │ } + + unused variable f. + +Fix this by: +- Prepending the variable name with `_` (like `_f`) to ignore that the variable is unused. +- Use the variable somewhere. \ No newline at end of file diff --git a/jscomp/build_tests/super_errors/fixtures/unused_variable.res b/jscomp/build_tests/super_errors/fixtures/unused_variable.res new file mode 100644 index 0000000000..42d2252b3d --- /dev/null +++ b/jscomp/build_tests/super_errors/fixtures/unused_variable.res @@ -0,0 +1,4 @@ +let x = { + let f = 12 + 13 +} diff --git a/jscomp/ext/warnings.ml b/jscomp/ext/warnings.ml index 06233bf643..00e47144a8 100644 --- a/jscomp/ext/warnings.ml +++ b/jscomp/ext/warnings.ml @@ -378,7 +378,8 @@ let message = function | All_clauses_guarded -> "this pattern-matching is not exhaustive.\n\ All clauses in this pattern-matching are guarded." - | Unused_var v | Unused_var_strict v -> "unused variable " ^ v ^ "." + | Unused_var v | Unused_var_strict v -> + Format.sprintf "unused variable %s.\n\nFix this by:\n- Prepending the variable name with `_` (like `_%s`) to ignore that the variable is unused.\n- Use the variable somewhere." v v | Wildcard_arg_to_constant_constr -> "wildcard pattern given as argument to a constant constructor" | Eol_in_string ->