-
Notifications
You must be signed in to change notification settings - Fork 833
Add "," as separator for pattern matching on multiple named discriminated unions fields #18833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1799aaf
55507e9
1738018
65f5bb6
0c97b9d
6f2b706
e8f1bb0
75d8f5e
4f2e97e
63be5d5
4248f2a
cc96217
e270b88
e0cc65a
1e29d58
1470bf9
8988215
74712e8
967c4a9
a30cef4
5fa0480
15e3d34
b7ffcf8
5bde641
0f7c23c
6a6843c
d11dd4a
30fc9a2
b5b8830
a2ed26a
4d87685
1a9497b
8207cba
b91ef61
db80eaf
6261517
d2036e8
43caa8a
b7706c1
7e07f5f
5fcf413
ac08b8c
0970831
3287bce
ce845f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1112,7 +1112,7 @@ module SynExpr = | |
| match recordFields with | ||
| | [] -> false | ||
| | SynExprRecordField(expr = Some(SynExpr.Paren(expr = Is inner)); blockSeparator = Some _) :: SynExprRecordField( | ||
| fieldName = SynLongIdent(id = id :: _), _) :: _ -> problematic inner.Range id.idRange | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
| fieldName = (SynLongIdent(id = id :: _), _)) :: _ -> problematic inner.Range id.idRange | ||
| | _ :: recordFields -> loop recordFields | ||
|
|
||
| loop recordFields | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
|
||
| namespace Conformance.PatternMatching | ||
|
|
||
| open Xunit | ||
| open FSharp.Test | ||
| open FSharp.Test.Compiler | ||
|
|
||
| module NamedPatPairs = | ||
| [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"NamedPatPairs01.fs"|])>] | ||
| let ``Preview: NamedPatPairs - NamedPatPairs01_fs`` compilation = | ||
| compilation | ||
| |> ignoreWarnings | ||
| |> withLangVersionPreview | ||
| |> typecheck | ||
| |> shouldSucceed | ||
|
|
||
| [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"NamedPatPairs01.fs"|])>] | ||
| let ``Version9 NamedPatPairs - NamedPatPairs01_fs`` compilation = | ||
| compilation | ||
| |> ignoreWarnings | ||
| |> withLangVersion90 | ||
| |> typecheck | ||
| |> shouldFail | ||
| |> withDiagnostics [ | ||
| (Error 3350, Line 8, Col 18, Line 8, Col 19, "Feature 'Allow comma as separator for pattern matching on multiple named discriminated unions fields' is not available in F# 9.0. Please use language version 'PREVIEW' or greater."); | ||
| (Error 3350, Line 9, Col 18, Line 9, Col 19, "Feature 'Allow comma as separator for pattern matching on multiple named discriminated unions fields' is not available in F# 9.0. Please use language version 'PREVIEW' or greater."); | ||
| (Error 3350, Line 9, Col 25, Line 9, Col 26, "Feature 'Allow comma as separator for pattern matching on multiple named discriminated unions fields' is not available in F# 9.0. Please use language version 'PREVIEW' or greater."); | ||
| (Error 3350, Line 19, Col 18, Line 19, Col 19, "Feature 'Allow comma as separator for pattern matching on multiple named discriminated unions fields' is not available in F# 9.0. Please use language version 'PREVIEW' or greater."); | ||
| (Error 3350, Line 20, Col 18, Line 20, Col 19, "Feature 'Allow comma as separator for pattern matching on multiple named discriminated unions fields' is not available in F# 9.0. Please use language version 'PREVIEW' or greater."); | ||
| (Error 3350, Line 21, Col 25, Line 21, Col 26, "Feature 'Allow comma as separator for pattern matching on multiple named discriminated unions fields' is not available in F# 9.0. Please use language version 'PREVIEW' or greater.") | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // #Conformance #PatternMatching #NamedPatPairs | ||
| type MyUnion = | ||
| | CaseA of a: int * b: string | ||
| | CaseB of x: float * y: bool * z: char | ||
|
|
||
| let testComma value = | ||
| match value with | ||
| | CaseA(a = x, b = y) -> sprintf "CaseA: a=%d, b=%s" x y | ||
| | CaseB(x = p, y = q, z = r) -> sprintf "CaseB: x=%f, y=%b, z=%c" p q r | ||
|
|
||
| let testSemicolon value = | ||
| match value with | ||
| | CaseA(a = x; b = y) -> sprintf "CaseA: a=%d, b=%s" x y | ||
| | CaseB(x = p; y = q; z = r) -> sprintf "CaseB: x=%f, y=%b, z=%c" p q r | ||
|
|
||
| let testMixed value = | ||
| match value with | ||
| | CaseA(a = x; b = y) -> sprintf "CaseA: a=%d, b=%s" x y | ||
| | CaseB(x = p, y = q; z = r) -> sprintf "CaseB: x=%f, y=%b, z=%c" p q r | ||
| | CaseA(a = x, b = y) -> sprintf "CaseA: a=%d, b=%s" x y | ||
| | CaseB(x = p; y = q, z = r) -> sprintf "CaseB: x=%f, y=%b, z=%c" p q r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing pattern matching code seems incorrect - it was missing the tuple parentheses that should have been there.
fieldName = lid, _should have beenfieldName = (lid, _).