-
Notifications
You must be signed in to change notification settings - Fork 832
Error for primary constructor in delegate definition #13078
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
Merged
vzarytovskii
merged 15 commits into
dotnet:main
from
edgarfgp:no-syntax-error-for-primary-constructor-in-delegate-definition
Jun 2, 2022
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2f7d9fe
Error for primary constructor in delegate definition
edgarfgp 6822d72
Move unit test from fsharpqa -> ComponentTests
edgarfgp f81e6a1
Update tests
edgarfgp a73fd0f
Use runFsi instead of compile
edgarfgp 649c3a7
Add error message
edgarfgp 1168394
Update the Dev guide
edgarfgp b693d1c
Update Unit tests
edgarfgp 56bb5c8
Add more unit tests
edgarfgp f190952
Add BaseLine test
edgarfgp 9c70231
Fix PR comments
edgarfgp 6231d13
Update net06.fs baseline tests
edgarfgp b5c1b44
Simplify the invalid_delegate_definition.err.bsl
edgarfgp 9379742
Reuse FS0552 error message to avoid having to create a new one
edgarfgp 8225846
Update unit tests to match the error message
edgarfgp d903a92
Update DEVGUIDE.md
edgarfgp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
45 changes: 45 additions & 0 deletions
45
tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/DelegateDefinition.fs
This file contains hidden or 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,45 @@ | ||
| // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
|
||
| namespace FSharp.Compiler.ComponentTests.Conformance.DelegateTypes | ||
|
|
||
| open Xunit | ||
| open FSharp.Test.Compiler | ||
|
|
||
| module DelegateDefinition = | ||
|
|
||
| [<Fact>] | ||
| let ``Delegate definition with primary constructor and argument.`` () = | ||
| FSharp | ||
| """ | ||
| namespace FSharpTest | ||
| type T(x: int) = | ||
| delegate of int -> int | ||
| """ | ||
| |> compile | ||
| |> shouldFail | ||
| |> withErrorCode 552 | ||
| |> withErrorMessage "Only class types may take value arguments" | ||
|
|
||
| [<Fact>] | ||
| let ``Delegate definition with primary constructor no argument.`` () = | ||
| FSharp | ||
| """ | ||
| namespace FSharpTest | ||
| type T() = | ||
| delegate of int -> int | ||
| """ | ||
| |> compile | ||
| |> shouldFail | ||
| |> withErrorCode 552 | ||
| |> withErrorMessage "Only class types may take value arguments" | ||
|
|
||
| [<Fact>] | ||
| let ``Delegate definition`` () = | ||
| FSharp | ||
| """ | ||
| namespace FSharpTest | ||
| type T = | ||
| delegate of int -> int | ||
| """ | ||
| |> compile | ||
| |> shouldSucceed |
5 changes: 5 additions & 0 deletions
5
...s/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs
This file contains hidden or 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,5 @@ | ||
| type T(x: int) = | ||
vzarytovskii marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| delegate of int -> int | ||
|
|
||
| type T() = | ||
| delegate of int -> int | ||
3 changes: 3 additions & 0 deletions
3
....Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl
This file contains hidden or 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,3 @@ | ||
| invalid_delegate_definition.fs (1,6)-(1,15) Only class types may take value arguments | ||
| invalid_delegate_definition.fs (4,6)-(1,9) Only class types may take value arguments | ||
|
|
This file contains hidden or 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 hidden or 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
3 changes: 1 addition & 2 deletions
3
tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/env.lst
This file contains hidden or 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,10 +1,9 @@ | ||
| SOURCE=ByrefArguments01.fs # ByrefArguments01.fs | ||
| SOURCE=E_InvalidSignature01.fs # E_InvalidSignature01.fs | ||
| SOURCE=E_InvalidSignature02.fs # E_InvalidSignature02.fs | ||
|
|
||
| SOURCE=ValidSignature_MultiArg01.fs # ValidSignature_MultiArg01.fs | ||
| SOURCE=ValidSignature_ReturningValues01.fs # ValidSignature_ReturningValues01.fs | ||
|
|
||
| # This test has a dependency on NetFx3.5 (i.e. CSC_PIPE must be 3.5 or better) | ||
| # For this reason, we exclude it from MT | ||
| NoMT SOURCE=DelegateBindingInvoke01.fs PRECMD="\$CSC_PIPE /t:library IDelegateBinding.cs" SCFLAGS="-r:IDelegateBinding.dll" # DelegateBindingInvoke01.fs | ||
| NoMT SOURCE=DelegateBindingInvoke01.fs PRECMD="\$CSC_PIPE /t:library IDelegateBinding.cs" SCFLAGS="-r:IDelegateBinding.dll" # DelegateBindingInvoke01.fs |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.