Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1799aaf
make attribute targets mismatches a warning and not an error.
edgarfgp Apr 23, 2025
55507e9
release notes
edgarfgp Apr 23, 2025
1738018
update tests
edgarfgp Apr 23, 2025
65f5bb6
Merge branch 'main' into fix-attr-targets
edgarfgp Apr 24, 2025
0c97b9d
Merge branch 'main' into fix-attr-targets
edgarfgp Apr 27, 2025
6f2b706
update baselines
edgarfgp Apr 29, 2025
e8f1bb0
Merge branch 'main' into fix-attr-targets
edgarfgp Apr 29, 2025
75d8f5e
Update baselines
edgarfgp Apr 29, 2025
4f2e97e
Merge branch 'fix-attr-targets' of github.com:edgarfgp/fsharp into fi…
edgarfgp Apr 29, 2025
63be5d5
Merge branch 'main' into fix-attr-targets
edgarfgp Apr 30, 2025
4248f2a
Move attribute form logic to an AP
edgarfgp Apr 30, 2025
cc96217
Merge branch 'main' into fix-attr-targets
edgarfgp May 1, 2025
e270b88
Merge branch 'main' into fix-attr-targets
edgarfgp May 1, 2025
e0cc65a
Merge branch 'main' into fix-attr-targets
edgarfgp May 2, 2025
1e29d58
Merge branch 'main' into fix-attr-targets
edgarfgp May 5, 2025
1470bf9
Merge branch 'main' into fix-attr-targets
edgarfgp May 6, 2025
8988215
Merge branch 'main' into fix-attr-targets
edgarfgp May 7, 2025
74712e8
Merge branch 'main' into fix-attr-targets
edgarfgp May 12, 2025
967c4a9
Merge branch 'main' of github.com:edgarfgp/fsharp
edgarfgp May 13, 2025
a30cef4
Merge branch 'dotnet:main' into main
edgarfgp May 22, 2025
5fa0480
Merge branch 'dotnet:main' into main
edgarfgp May 24, 2025
15e3d34
Merge branch 'dotnet:main' into main
edgarfgp May 29, 2025
b7ffcf8
Merge branch 'dotnet:main' into main
edgarfgp Jun 6, 2025
5bde641
Merge branch 'dotnet:main' into main
edgarfgp Jul 26, 2025
0f7c23c
Merge branch 'dotnet:main' into main
edgarfgp Jul 29, 2025
6a6843c
Merge branch 'dotnet:main' into main
edgarfgp Aug 4, 2025
d11dd4a
Merge branch 'dotnet:main' into main
edgarfgp Aug 4, 2025
30fc9a2
Merge branch 'dotnet:main' into main
edgarfgp Aug 5, 2025
b5b8830
Add "," as separator for pattern matching on multiple named discrimin…
edgarfgp Aug 9, 2025
a2ed26a
fix build
edgarfgp Aug 10, 2025
4d87685
Merge branch 'main' into fs-lang-957
edgarfgp Aug 10, 2025
1a9497b
Component Tests
edgarfgp Aug 10, 2025
8207cba
Add LanguageFeature
edgarfgp Aug 10, 2025
b91ef61
Merge branch 'main' into fs-lang-957
edgarfgp Aug 11, 2025
db80eaf
Rename LanguageFeature and use it in the parser
edgarfgp Aug 13, 2025
6261517
update tests
edgarfgp Aug 13, 2025
d2036e8
release notes
edgarfgp Aug 13, 2025
43caa8a
Merge branch 'main' into fs-lang-957
edgarfgp Aug 13, 2025
b7706c1
format code
edgarfgp Aug 13, 2025
7e07f5f
Merge branch 'main' into fs-lang-957
edgarfgp Aug 14, 2025
5fcf413
remove duplicated rules
edgarfgp Aug 15, 2025
ac08b8c
Merge branch 'fs-lang-957' of github.com:edgarfgp/fsharp into fs-lang…
edgarfgp Aug 15, 2025
0970831
more tests
edgarfgp Aug 15, 2025
3287bce
update pars.fsy
edgarfgp Aug 18, 2025
ce845f3
Simplify rules
edgarfgp Aug 22, 2025
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 docs/release-notes/.FSharp.Compiler.Service/10.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

### Changed
* Use `errorR` instead of `error` in `CheckDeclarations.fs` when possible. ([PR #18645](https://github.com/dotnet/fsharp/pull/18645))
* Allow comma as separator for pattern matching on multiple named discriminated unions fields. ([PR #18833](https://github.com/dotnet/fsharp/pull/18833))

### Breaking Changes

Expand Down
1 change: 1 addition & 0 deletions docs/release-notes/.Language/preview.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Allow `let!`, `use!`, `and!` type annotations without requiring parentheses (([PR #18508](https://github.com/dotnet/fsharp/pull/18508) and [PR #18682](https://github.com/dotnet/fsharp/pull/18682)))
* Exception names are now validated for illegal characters using the same mechanism as types/modules/namespaces ([Issue #18763](https://github.com/dotnet/fsharp/issues/18763))
* Support tail calls in computation expressions ([PR #18804](https://github.com/dotnet/fsharp/pull/18804))
* Allow comma as separator for pattern matching on multiple named discriminated unions fields. ([PR #18833](https://github.com/dotnet/fsharp/pull/18833))

### Fixed

Expand Down
1 change: 1 addition & 0 deletions src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,7 @@ featureWarningWhenMultipleRecdTypeChoice,"Raises warnings when multiple record t
featureImprovedImpliedArgumentNames,"Improved implied argument names"
featureStrictIndentation,"Raises errors on incorrect indentation, allows better recovery and analysis during editing"
featureConstraintIntersectionOnFlexibleTypes,"Constraint intersection on flexible types"
featureAllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields,"Allow comma as separator for pattern matching on multiple named discriminated unions fields"
featureChkNotTailRecursive,"Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way."
featureWhileBang,"'while!' expression"
featureExtendedFixedBindings,"extended fixed bindings for byref and GetPinnableReference"
Expand Down
4 changes: 4 additions & 0 deletions src/Compiler/Facilities/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ type LanguageFeature =
| ScopedNowarn
| AllowTypedLetUseAndBang
| ReturnFromFinal
| AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields

/// LanguageVersion management
type LanguageVersion(versionText) =
Expand Down Expand Up @@ -243,6 +244,7 @@ type LanguageVersion(versionText) =

// F# preview (still preview in 10.0)
LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work
LanguageFeature.AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields, previewVersion
]

static let defaultLanguageVersion = LanguageVersion("default")
Expand Down Expand Up @@ -412,6 +414,8 @@ type LanguageVersion(versionText) =
| LanguageFeature.ScopedNowarn -> FSComp.SR.featureScopedNowarn ()
| LanguageFeature.AllowTypedLetUseAndBang -> FSComp.SR.featureAllowLetOrUseBangTypeAnnotationWithoutParens ()
| LanguageFeature.ReturnFromFinal -> FSComp.SR.featureReturnFromFinal ()
| LanguageFeature.AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields ->
FSComp.SR.featureAllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields ()

/// Get a version string associated with the given feature.
static member GetFeatureVersionString feature =
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Facilities/LanguageFeatures.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type LanguageFeature =
| ScopedNowarn
| AllowTypedLetUseAndBang
| ReturnFromFinal
| AllowCommaAsSeparatorForPatternMatchingOnMultipleNamedDiscriminatedUnionsFields

/// LanguageVersion management
type LanguageVersion =
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Service/ServiceParsedInputOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ module ParsedInput =
| SyntaxNode.SynExpr(SynExpr.Record(None, _, fields, _)) :: _ ->
let isFirstField =
match field, fields with
| Some contextLid, SynExprRecordField(fieldName = lid, _) :: _ -> contextLid.Range = lid.Range
Copy link
Contributor Author

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 been fieldName = (lid, _).

| Some contextLid, SynExprRecordField(fieldName = (lid, _)) :: _ -> contextLid.Range = lid.Range
| _ -> false

RecordContext.New(completionPath, isFirstField)
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Service/SynExpr.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down
24 changes: 21 additions & 3 deletions src/Compiler/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -3655,13 +3655,16 @@ conjPatternElements:
{ $3 :: $1 :: [] }

namePatPairs:
| namePatPair opt_seps
| namePatPair opt_namePatSep
{ [$1] }

| namePatPair seps namePatPairs
| namePatPair namePatSep namePatPairs
{ $1 :: $3 }

| namePatPair seps seps namePatPairs
| namePatPair namePatSep UNDERSCORE
{ [$1] }

| namePatPair namePatSep namePatSep namePatPairs
{ reportParseErrorAt (rhs parseState 3) (FSComp.SR.parsExpectingPattern ())
($1 :: $4) }

Expand Down Expand Up @@ -3700,6 +3703,7 @@ constrPattern:
let m = unionRanges (rhs2 parseState 1 2) argsM
SynPat.LongIdent(lid, None, Some $2, args, vis, m) }


| atomicPatternLongIdent atomicPatsOrNamePatPairs %prec pat_app
{ let vis, lid = $1
let args, argsM = $2
Expand Down Expand Up @@ -6987,6 +6991,20 @@ seps:
| OBLOCKSEP SEMICOLON { Some (rhs parseState 2) }
| SEMICOLON OBLOCKSEP { Some (rhs parseState 1) }

/* Unified separator for name pattern pairs that handles both semicolon and comma */
namePatSep:
| OBLOCKSEP { None }
| SEMICOLON { Some (rhs parseState 1) }
| COMMA { Some (rhs parseState 1) }
| OBLOCKSEP SEMICOLON { Some (rhs parseState 2) }
| OBLOCKSEP COMMA { Some (rhs parseState 2) }
| SEMICOLON OBLOCKSEP { Some (rhs parseState 1) }
| COMMA OBLOCKSEP { Some (rhs parseState 1) }

opt_namePatSep:
| namePatSep { }
| /* EMPTY */ { }

/* An 'end' that's optional only in #light, where an ODECLEND gets inserted, and explicit 'end's get converted to OEND */
declEnd:
| ODECLEND
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hant.xlf

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
Loading
Loading