Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion DEVGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,11 @@ If your changes involve modifying the list of language keywords in any way, (e.g
```shell
dotnet build src\Compiler /t:UpdateXlf
```
If you are on a Mac, you can run this command from the root of the repository:

This only works on Windows/.NETStandard framework, so changing this from any other platform requires editing and syncing all of the XLF files manually.
```shell
sh build.sh -c Release
```

## Updating baselines in tests

Expand Down
9 changes: 8 additions & 1 deletion src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3985,7 +3985,13 @@ module EstablishTypeDefinitionCores =
match fields' with
| rf :: _ -> errorR (Error(FSComp.SR.tcInterfaceTypesAndDelegatesCannotContainFields(), rf.Range))
| _ -> ()


let primaryConstructorInDelegateCheck(implicitCtorSynPats : SynSimplePats option) =
match implicitCtorSynPats with
| None -> ()
| Some spats ->
let ctorArgNames, _ = TcSimplePatsOfUnknownType cenv true CheckCxs envinner tpenv spats
if not ctorArgNames.IsEmpty then errorR (Error(FSComp.SR.parsOnlyClassCanTakeValueArguments(), m))

let envinner = AddDeclaredTypars CheckForDuplicateTypars (tycon.Typars m) envinner
let envinner = MakeInnerEnvForTyconRef envinner thisTyconRef false
Expand Down Expand Up @@ -4182,6 +4188,7 @@ module EstablishTypeDefinitionCores =
noAllowNullLiteralAttributeCheck()
noAbstractClassAttributeCheck()
noFieldsCheck userFields
primaryConstructorInDelegateCheck(implicitCtorSynPats)
let tyR, _ = TcTypeAndRecover cenv NoNewTypars CheckCxs ItemOccurence.UseInType envinner tpenv ty
let _, _, curriedArgInfos, returnTy, _ = GetTopValTypeInCompiledForm g (arity |> TranslateSynValInfo m (TcAttributes cenv envinner) |> TranslatePartialValReprInfo []) 0 tyR m
if curriedArgInfos.Length < 1 then error(Error(FSComp.SR.tcInvalidDelegateSpecification(), m))
Expand Down
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type T(x: int) =
delegate of int -> int

type T() =
delegate of int -> int
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

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<Compile Include="Conformance\ClassTypes\ExplicitObjectConstructors\ExplicitObjectConstructors.fs" />
<Compile Include="Conformance\ClassTypes\ImplicitObjectConstructors\ImplicitObjectConstructors.fs" />
<Compile Include="Conformance\ClassTypes\ValueRestriction\ValueRestriction.fs" />
<Compile Include="Conformance\DelegateTypes\DelegateDefinition.fs" />
<Compile Include="Conformance\DeclarationElements\AccessibilityAnnotations\Basic\Basic.fs" />
<Compile Include="Conformance\DeclarationElements\AccessibilityAnnotations\OnOverridesAndIFaceImpl\OnOverridesAndIFaceImpl.fs" />
<Compile Include="Conformance\DeclarationElements\AccessibilityAnnotations\OnTypeMembers\OnTypeMembers.fs" />
Expand Down
2 changes: 1 addition & 1 deletion tests/fsharp/typecheck/sigs/neg06.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type BadSealedInterface =
type BadSealedAbbreviatedType = System.Object

[<Sealed>]
type UnnecessarilySealedDelegate() = delegate of int -> int
type UnnecessarilySealedDelegate = delegate of int -> int

type BadExtensionOfSealedType() =
class
Expand Down
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