Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#### :nail_care: Polish

- Add some context to error message for unused variables. https://github.com/rescript-lang/rescript-compiler/pull/7050
- Improve error messages for pattern matching on option vs non-option, and vice versa. https://github.com/rescript-lang/rescript-compiler/pull/7035
- Improve bigint literal comparison. https://github.com/rescript-lang/rescript-compiler/pull/7029
- Improve output of `@variadic` bindings. https://github.com/rescript-lang/rescript-compiler/pull/7030
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
- Using the variable somewhere.
4 changes: 4 additions & 0 deletions jscomp/build_tests/super_errors/fixtures/unused_variable.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let x = {
let f = 12
13
}
3 changes: 2 additions & 1 deletion jscomp/ext/warnings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
Loading