-
Notifications
You must be signed in to change notification settings - Fork 803
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow parameter-less CustomOperation (#16475)
- Loading branch information
1 parent
8447fa0
commit ec08a4c
Showing
14 changed files
with
170 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
### Added | ||
|
||
* More inlines for Result module. ([PR #16106](https://github.com/dotnet/fsharp/pull/16106)) | ||
* Added a new parameterless constructor for `CustomOperationAttribute` ([PR #16475](https://github.com/dotnet/fsharp/pull/16475), part of implementation for [fslang-suggestions/1250](https://github.com/fsharp/fslang-suggestions/issues/1250)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ompiler.ComponentTests/Conformance/Expressions/ComputationExpressions/CustomOperations.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace Conformance.Expressions.ComputationExpressions | ||
|
||
open Xunit | ||
open FSharp.Test.Compiler | ||
|
||
module CustomOperations = | ||
|
||
[<Fact>] | ||
let ``[<CustomOperation>] without explicit name is allowed, uses method name as operation name`` () = | ||
FSharp """ | ||
module CustomOperationTest | ||
type CBuilder() = | ||
[<CustomOperation>] | ||
member this.Foo _ = "Foo" | ||
[<CustomOperation>] | ||
member this.foo _ = "foo" | ||
[<CustomOperation("")>] | ||
member this.bar _ = "bar" | ||
member this.Yield _ = () | ||
member this.Zero _ = () | ||
[<EntryPoint>] | ||
let main _ = | ||
let cb = CBuilder() | ||
let x = cb { Foo } | ||
let y = cb { foo } | ||
let z = cb { bar } | ||
printfn $"{x}" | ||
printfn $"{y}" | ||
if x <> "Foo" then | ||
failwith "not Foo" | ||
if y <> "foo" then | ||
failwith "not foo" | ||
if z <> "bar" then | ||
failwith "not bar" | ||
0 | ||
""" | ||
|> asExe | ||
|> compileAndRun | ||
|> shouldSucceed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.