diff --git a/CHANGELOG.md b/CHANGELOG.md index ab4d062b94..d6707c1d31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,9 @@ - Fix making the static import for the dynamic import of external ffi https://github.com/rescript-lang/rescript-compiler/pull/6664 #### :nail-care: Polish + - Omit `undefined` in external function calls for trailing optional arguments when not supplied. https://github.com/rescript-lang/rescript-compiler/pull/6653 +- Make pattern match suggestions to be easier to copy-paste. https://github.com/rescript-lang/rescript-compiler/pull/6656 # 11.1.0-rc.3 diff --git a/jscomp/build_tests/super_errors/expected/warnings4.res.expected b/jscomp/build_tests/super_errors/expected/warnings4.res.expected index dfa23450b8..8591875997 100644 --- a/jscomp/build_tests/super_errors/expected/warnings4.res.expected +++ b/jscomp/build_tests/super_errors/expected/warnings4.res.expected @@ -10,4 +10,4 @@ 14 │ You forgot to handle a possible case here, for example: - #second(_) | #fourth | #third \ No newline at end of file + | #second(_) | #fourth | #third diff --git a/jscomp/build_tests/super_errors/expected/warnings5.res.expected b/jscomp/build_tests/super_errors/expected/warnings5.res.expected index 91026741ff..1cb0e9757d 100644 --- a/jscomp/build_tests/super_errors/expected/warnings5.res.expected +++ b/jscomp/build_tests/super_errors/expected/warnings5.res.expected @@ -24,7 +24,7 @@ Either bind these labels explicitly or add ', _' to the pattern. 15 │ switch y { You forgot to handle a possible case here, for example: - {otherValue: true, _} + | {otherValue: true, _} Warning number 9 @@ -52,7 +52,7 @@ Either bind these labels explicitly or add ', _' to the pattern. 19 │ let arr = [1] You forgot to handle a possible case here, for example: - {typ: WithPayload(false), _} + | {typ: WithPayload(false), _} | {typ: Variant | One | Two | Three | Four | Five | Six | Seven(_), _} @@ -68,7 +68,7 @@ Either bind these labels explicitly or add ', _' to the pattern. 25 │ switch arr { You forgot to handle a possible case here, for example: - [_] + | [_] Warning number 8 @@ -83,7 +83,7 @@ Either bind these labels explicitly or add ', _' to the pattern. 29 │ switch arr { You forgot to handle a possible case here, for example: - [] + | [] Warning number 8 @@ -98,7 +98,7 @@ Either bind these labels explicitly or add ', _' to the pattern. 33 │ let lst = list{} You forgot to handle a possible case here, for example: - [1, 0] | [0, _] | [] + | [1, 0] | [0, _] | [] Warning number 8 @@ -113,7 +113,7 @@ Either bind these labels explicitly or add ', _' to the pattern. 39 │ switch lst { You forgot to handle a possible case here, for example: - list{_, ..._} + | list{_, ..._} Warning number 8 @@ -128,7 +128,7 @@ Either bind these labels explicitly or add ', _' to the pattern. 43 │ switch lst { You forgot to handle a possible case here, for example: - list{1, 2, _, ..._} | list{1, 0, ..._} | list{1} | list{0, ..._} | list{} + | list{1, 2, _, ..._} | list{1, 0, ..._} | list{1} | list{0, ..._} | list{} Warning number 8 @@ -143,7 +143,7 @@ Either bind these labels explicitly or add ', _' to the pattern. 47 │ switch "abc" { You forgot to handle a possible case here, for example: - list{1, _, ..._} | list{0, ..._} | list{} + | list{1, _, ..._} | list{0, ..._} | list{} Warning number 8 @@ -158,7 +158,7 @@ Either bind these labels explicitly or add ', _' to the pattern. 51 │ switch 0 { You forgot to handle a possible case here, for example: - "*" + | "*" Warning number 8 @@ -173,7 +173,7 @@ Either bind these labels explicitly or add ', _' to the pattern. 55 │ let tuple = (1, true) You forgot to handle a possible case here, for example: - 0 + | 0 Warning number 8 @@ -187,4 +187,4 @@ Either bind these labels explicitly or add ', _' to the pattern. 60 │ You forgot to handle a possible case here, for example: - (_, true) \ No newline at end of file + | (_, true) diff --git a/jscomp/ml/parmatch.ml b/jscomp/ml/parmatch.ml index e06991290b..d93f1a63df 100644 --- a/jscomp/ml/parmatch.ml +++ b/jscomp/ml/parmatch.ml @@ -2099,6 +2099,7 @@ let do_check_partial ?pred exhaust loc casel pss = match pss with let errmsg = try let buf = Buffer.create 16 in + Buffer.add_string buf "| "; Buffer.add_string buf (!print_res_pat v); begin match check_partial_all v casel with | None -> ()