From 2f7d9fe72ee975eeb48db71967bb75863606d0b9 Mon Sep 17 00:00:00 2001 From: Edgar Date: Sun, 1 May 2022 21:54:36 +0100 Subject: [PATCH 01/15] Error for primary constructor in delegate definition --- .../DelegateTypes/E_InvalidDelegateDefinition.fs | 11 +++++++++++ .../DelegateTypes/env.lst | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/E_InvalidDelegateDefinition.fs diff --git a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/E_InvalidDelegateDefinition.fs b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/E_InvalidDelegateDefinition.fs new file mode 100644 index 00000000000..2bcea8caa69 --- /dev/null +++ b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/E_InvalidDelegateDefinition.fs @@ -0,0 +1,11 @@ +// #Regression #Conformance #ObjectOrientedTypes #Delegates + +// Verify error when given an invalid delegate definition +//Illegal definition for runtime implemented delegate method. + +type InvalidDelegateDefinition(x: int) = + delegate of int -> int + +let invalidDelegate = InvalidDelegateDefinition(fun _ -> 1) + +exit 1 diff --git a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/env.lst b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/env.lst index bb9e0f2ae1f..62d6a23443d 100644 --- a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/env.lst +++ b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/env.lst @@ -1,10 +1,11 @@ SOURCE=ByrefArguments01.fs # ByrefArguments01.fs SOURCE=E_InvalidSignature01.fs # E_InvalidSignature01.fs SOURCE=E_InvalidSignature02.fs # E_InvalidSignature02.fs + SOURCE=E_InvalidDelegateDefinition.fs # E_InvalidDelegateDefinition.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 \ No newline at end of file +NoMT SOURCE=DelegateBindingInvoke01.fs PRECMD="\$CSC_PIPE /t:library IDelegateBinding.cs" SCFLAGS="-r:IDelegateBinding.dll" # DelegateBindingInvoke01.fs From 6822d72e686cc7d3352437112d0101acfdbf1296 Mon Sep 17 00:00:00 2001 From: Edgar Date: Tue, 3 May 2022 17:59:33 +0200 Subject: [PATCH 02/15] Move unit test from fsharpqa -> ComponentTests --- .../InvalidDelegateDefinition.fs | 20 +++++++++++++++++++ .../FSharp.Compiler.ComponentTests.fsproj | 1 + .../E_InvalidDelegateDefinition.fs | 11 ---------- .../DelegateTypes/env.lst | 2 -- 4 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs delete mode 100644 tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/E_InvalidDelegateDefinition.fs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs new file mode 100644 index 00000000000..5743a3bbec1 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs @@ -0,0 +1,20 @@ +// 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 InvalidDelegateDefinition = + + [] + let ``Illegal definition for runtime implemented delegate method.`` () = + FSharp """ +namespace FSharpTest + type T(x: int) = + delegate of int -> int + """ + |> compile + |> shouldFail + |> withErrorCode 193 + |> withErrorMessage "Illegal definition for runtime implemented delegate method." diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index a91bb7b00a2..570cb4545a7 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -93,6 +93,7 @@ + diff --git a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/E_InvalidDelegateDefinition.fs b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/E_InvalidDelegateDefinition.fs deleted file mode 100644 index 2bcea8caa69..00000000000 --- a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/E_InvalidDelegateDefinition.fs +++ /dev/null @@ -1,11 +0,0 @@ -// #Regression #Conformance #ObjectOrientedTypes #Delegates - -// Verify error when given an invalid delegate definition -//Illegal definition for runtime implemented delegate method. - -type InvalidDelegateDefinition(x: int) = - delegate of int -> int - -let invalidDelegate = InvalidDelegateDefinition(fun _ -> 1) - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/env.lst b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/env.lst index 62d6a23443d..e805eea233c 100644 --- a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/env.lst +++ b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/DelegateTypes/env.lst @@ -1,8 +1,6 @@ SOURCE=ByrefArguments01.fs # ByrefArguments01.fs SOURCE=E_InvalidSignature01.fs # E_InvalidSignature01.fs SOURCE=E_InvalidSignature02.fs # E_InvalidSignature02.fs - SOURCE=E_InvalidDelegateDefinition.fs # E_InvalidDelegateDefinition.fs - SOURCE=ValidSignature_MultiArg01.fs # ValidSignature_MultiArg01.fs SOURCE=ValidSignature_ReturningValues01.fs # ValidSignature_ReturningValues01.fs From f81e6a19fdf48fb8232bbbadcfeaaaf049cc1e5f Mon Sep 17 00:00:00 2001 From: Edgar Date: Tue, 3 May 2022 19:12:15 +0200 Subject: [PATCH 03/15] Update tests --- .../DelegateTypes/InvalidDelegateDefinition.fs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs index 5743a3bbec1..192b2f35c2b 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs @@ -10,9 +10,22 @@ module InvalidDelegateDefinition = [] let ``Illegal definition for runtime implemented delegate method.`` () = FSharp """ -namespace FSharpTest - type T(x: int) = +module FSharpTest = + type InvalidDelegateDefinition(x: int) = delegate of int -> int + let invalidDelegate = InvalidDelegateDefinition(fun _ -> 1) + """ + |> compile + |> shouldFail + |> withErrorCode 193 + |> withErrorMessage "Illegal definition for runtime implemented delegate method." + + [] + let ``Illegal definition for runtime implemented delegate method when using in a fsx.`` () = + Fsx """ + type InvalidDelegateDefinition(x: int) = + delegate of int -> int + let invalidDelegate = InvalidDelegateDefinition(fun _ -> 1) """ |> compile |> shouldFail From a73fd0f69828e8bfc603b2dd98b40ac5633f447a Mon Sep 17 00:00:00 2001 From: Edgar Date: Thu, 5 May 2022 18:51:38 +0200 Subject: [PATCH 04/15] Use runFsi instead of compile --- .../InvalidDelegateDefinition.fs | 31 +++++-------------- .../invalid_delegate_definition.fs | 5 +++ 2 files changed, 12 insertions(+), 24 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs index 192b2f35c2b..1e8fa59b654 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs @@ -4,30 +4,13 @@ namespace FSharp.Compiler.ComponentTests.Conformance.DelegateTypes open Xunit open FSharp.Test.Compiler +open FSharp.Test module InvalidDelegateDefinition = - - [] - let ``Illegal definition for runtime implemented delegate method.`` () = - FSharp """ -module FSharpTest = - type InvalidDelegateDefinition(x: int) = - delegate of int -> int - let invalidDelegate = InvalidDelegateDefinition(fun _ -> 1) - """ - |> compile - |> shouldFail - |> withErrorCode 193 - |> withErrorMessage "Illegal definition for runtime implemented delegate method." - - [] - let ``Illegal definition for runtime implemented delegate method when using in a fsx.`` () = - Fsx """ - type InvalidDelegateDefinition(x: int) = - delegate of int -> int - let invalidDelegate = InvalidDelegateDefinition(fun _ -> 1) - """ - |> compile + + [] + let ``invalid_delegate_definition.fs`` compilation = + compilation + |> asFsx + |> runFsi |> shouldFail - |> withErrorCode 193 - |> withErrorMessage "Illegal definition for runtime implemented delegate method." diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs new file mode 100644 index 00000000000..114326b4a3d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs @@ -0,0 +1,5 @@ + +#light + +type InvalidDelegateDefinition(x: int) = + delegate of int -> int From 649c3a75075638b098292ff064dce238630da52c Mon Sep 17 00:00:00 2001 From: Edgar Date: Wed, 25 May 2022 16:14:04 +0100 Subject: [PATCH 05/15] Add error message --- src/Compiler/FSComp.txt | 3 ++- src/Compiler/xlf/FSComp.txt.cs.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.de.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.es.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.fr.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.it.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.ja.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.ko.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.pl.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.ru.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.tr.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 +++++ 14 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index d59eaf4ff53..21d1bad32ab 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1643,4 +1643,5 @@ reprStateMachineInvalidForm,"The state machine has an unexpected form" 3520,invalidXmlDocPosition,"XML comment is not placed on a valid language element." 3521,tcInvalidMemberDeclNameMissingOrHasParen,"Invalid member declaration. The name of the member is missing or has parentheses." 3522,tcAnonRecdDuplicateFieldId,"The field '%s' appears multiple times in this record expression." -3523,tcAnonRecdTypeDuplicateFieldId,"The field '%s' appears multiple times in this anonymous record type." \ No newline at end of file +3523,tcAnonRecdTypeDuplicateFieldId,"The field '%s' appears multiple times in this anonymous record type." +3524,noArgumentsAreAllowedInDelegatePrimaryConstructor,"No argument are allowed in delegate primary constructor." diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 92860a2902f..24de986026f 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -412,6 +412,11 @@ Hlavička zdroje začínající na posunu {0} má chybný formát. + + No argument are allowed in delegate primary constructor. + No argument are allowed in delegate primary constructor. + + This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Tento výraz není funkcí a nedá se použít. Nechtěli jste získat k indexeru přístup přes expr[index]? diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 22bd16c63c3..b51ec6f178d 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -412,6 +412,11 @@ Der Ressourcenheader, der am Offset {0} beginnt, ist fehlerhaft formatiert. + + No argument are allowed in delegate primary constructor. + No argument are allowed in delegate primary constructor. + + This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Dieser Ausdruck ist keine Funktion und kann nicht angewendet werden. Wollten Sie auf den Indexer stattdessen über "expr[index]" zugreifen? diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 4dc904402bf..8d35ed0396c 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -412,6 +412,11 @@ El encabezado de los recursos que comienza en el desplazamiento {0} está mal formado. + + No argument are allowed in delegate primary constructor. + No argument are allowed in delegate primary constructor. + + This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Esta expresión no es una función y no se puede aplicar. ¿Quería acceder al indexador a través de "expr[index]"? diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 0c131e6353c..31765f13f7b 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -412,6 +412,11 @@ L'en-tête de ressource commençant au décalage {0} est mal formé. + + No argument are allowed in delegate primary constructor. + No argument are allowed in delegate primary constructor. + + This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Cette expression n'est pas une fonction et ne peut pas être appliquée. Souhaitiez-vous accéder à l'indexeur via « expr[index] »? diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 5a6035a7014..307189f43fc 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -412,6 +412,11 @@ L'intestazione di risorsa che inizia a partire dall'offset {0} non è valida. + + No argument are allowed in delegate primary constructor. + No argument are allowed in delegate primary constructor. + + This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Questa espressione non è una funzione e non può essere applicata. Si intendeva accedere all'indicizzatore tramite la sintassi 'expr[index]'? diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index d8f1be72618..075512ede91 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -412,6 +412,11 @@ オフセット {0} で始まるリソース ヘッダーの形式に誤りがあります。 + + No argument are allowed in delegate primary constructor. + No argument are allowed in delegate primary constructor. + + This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? この式は関数ではないため、適用できません。'expr[index]' によってインデクサーにアクセスしようとしましたか? diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 0cd7929d6ff..499b2989c92 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -412,6 +412,11 @@ 오프셋 {0}에서 시작하는 리소스 헤더의 형식이 잘못되었습니다. + + No argument are allowed in delegate primary constructor. + No argument are allowed in delegate primary constructor. + + This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? 이 식은 함수가 아니며 적용할 수 없습니다. 'expr[index]'를 통해 인덱서에 액세스하려고 했습니까? diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index f92eed64abc..be79c1c05d2 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -412,6 +412,11 @@ Nagłówek zasobu rozpoczynający się od przesunięcia {0} jest nieprawidłowo sformułowany. + + No argument are allowed in delegate primary constructor. + No argument are allowed in delegate primary constructor. + + This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? To wyrażenie nie jest funkcją i nie można go zastosować. Spróbuj uzyskać dostęp do indeksatora za pośrednictwem wyrażenia „expr[index]”? diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 0c6ceac112a..ebc86db2b73 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -412,6 +412,11 @@ O cabeçalho do recurso que começa no deslocamento {0} está malformado. + + No argument are allowed in delegate primary constructor. + No argument are allowed in delegate primary constructor. + + This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Essa expressão não é uma função e não pode ser aplicada. Você pretendia acessar o indexador por meio do 'expr[index]'? diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 22b93f16437..c6210dc58bc 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -412,6 +412,11 @@ Заголовок ресурса некорректен начиная со смещения {0}. + + No argument are allowed in delegate primary constructor. + No argument are allowed in delegate primary constructor. + + This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Это выражение не является функцией, и применить его невозможно. Вы хотели обратиться к индексатору с помощью "expr[index]"? diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 3a720bf0f0d..0e04faa4dbc 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -412,6 +412,11 @@ {0} uzaklığında başlayan kaynak üst bilgisi hatalı biçimlendirilmiş. + + No argument are allowed in delegate primary constructor. + No argument are allowed in delegate primary constructor. + + This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Bu ifade bir fonksiyon değildir ve uygulanamaz. Dizin oluşturucuya “expr[index]” aracılığıyla mı erişmeyi düşündünüz? diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index f9eea243b93..0d669ac4fa7 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -412,6 +412,11 @@ 以偏移量 {0} 开始的资源标头格式不正确。 + + No argument are allowed in delegate primary constructor. + No argument are allowed in delegate primary constructor. + + This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? 此表达式不是函数,无法应用。是否曾打算通过 expr[index] 访问索引器? diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index d05d8005fea..7c0aa1c60e8 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -412,6 +412,11 @@ 從位移 {0} 開始的資源標頭格式錯誤。 + + No argument are allowed in delegate primary constructor. + No argument are allowed in delegate primary constructor. + + This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? 此運算式並非函式,因而無法套用。您要用 'expr[index]' 存取索引子嗎? From 1168394e4f5a284a4183948b9856b3569ccad63b Mon Sep 17 00:00:00 2001 From: Edgar Date: Wed, 25 May 2022 16:20:32 +0100 Subject: [PATCH 06/15] Update the Dev guide --- DEVGUIDE.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DEVGUIDE.md b/DEVGUIDE.md index 9e0fbb2cd3f..2be5ae6cef5 100644 --- a/DEVGUIDE.md +++ b/DEVGUIDE.md @@ -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 +sudo sh build.sh -c Release +``` ## Updating baselines in tests From b693d1cd5934f3fa09e8cc7541bd56d9a5da4619 Mon Sep 17 00:00:00 2001 From: Edgar Date: Wed, 25 May 2022 16:27:51 +0100 Subject: [PATCH 07/15] Update Unit tests --- src/Compiler/Checking/CheckDeclarations.fs | 10 +++- .../InvalidDelegateDefinition.fs | 56 ++++++++++++++++--- .../invalid_delegate_definition.fs | 5 -- 3 files changed, 58 insertions(+), 13 deletions(-) delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 0086fb44d2f..1f96fb0bff2 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -3985,7 +3985,14 @@ module EstablishTypeDefinitionCores = match fields' with | rf :: _ -> errorR (Error(FSComp.SR.tcInterfaceTypesAndDelegatesCannotContainFields(), rf.Range)) | _ -> () - + + let primaryConstructorInDelegateCheck(tyCon: Tycon, implicitCtorSynPats : SynSimplePats option) = + match implicitCtorSynPats with + | None -> () + | Some spats -> + if tyCon.IsFSharpDelegateTycon then + let ctorArgNames, _ = TcSimplePatsOfUnknownType cenv true CheckCxs envinner tpenv spats + if not ctorArgNames.IsEmpty then errorR (Error(FSComp.SR.noArgumentsAreAllowedInDelegatePrimaryConstructor(), m)) let envinner = AddDeclaredTypars CheckForDuplicateTypars (tycon.Typars m) envinner let envinner = MakeInnerEnvForTyconRef envinner thisTyconRef false @@ -4182,6 +4189,7 @@ module EstablishTypeDefinitionCores = noAllowNullLiteralAttributeCheck() noAbstractClassAttributeCheck() noFieldsCheck userFields + primaryConstructorInDelegateCheck(tycon, 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)) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs index 1e8fa59b654..4dba28df811 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs @@ -4,13 +4,55 @@ namespace FSharp.Compiler.ComponentTests.Conformance.DelegateTypes open Xunit open FSharp.Test.Compiler -open FSharp.Test module InvalidDelegateDefinition = - - [] - let ``invalid_delegate_definition.fs`` compilation = - compilation - |> asFsx - |> runFsi + +// [] +// let ``FSX Delegate primary constructor with argument.`` () = +// Fsx +// """ +//namespace FSharpTest +// type T(x: int) = +// delegate of int -> int +// """ +// |> asExe +// |> compileExeAndRun +// |> shouldFail +// |> withErrorCode 3524 +// |> withErrorMessage "No argument are allowed in delegate primary constructor." +// +// [] +// let ``FSX Delegate primary constructor with no argument.`` () = +// Fsx +// """ +//namespace FSharpTest +// type T() = +// delegate of int -> int +// """ +// |> asExe +// |> compileExeAndRun +// |> shouldSucceed +// + [] + let ``FSharp Delegate primary constructor with argument.`` () = + FSharp + """ +namespace FSharpTest + type T(x: int) = + delegate of int -> int + """ + |> compile |> shouldFail + |> withErrorCode 3524 + |> withErrorMessage "No argument are allowed in delegate primary constructor." + + [] + let ``FSharp Delegate primary constructor with no argument`` () = + FSharp + """ +namespace FSharpTest + type T() = + delegate of int -> int + """ + |> compile + |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs deleted file mode 100644 index 114326b4a3d..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs +++ /dev/null @@ -1,5 +0,0 @@ - -#light - -type InvalidDelegateDefinition(x: int) = - delegate of int -> int From 56bb5c8e0d17e636eff46b1975ffe3d443620d0e Mon Sep 17 00:00:00 2001 From: Edgar Date: Wed, 25 May 2022 18:50:30 +0100 Subject: [PATCH 08/15] Add more unit tests --- .../DelegateTypes/DelegateDefinition.fs | 45 ++++++++++++++ .../InvalidDelegateDefinition.fs | 58 ------------------- .../FSharp.Compiler.ComponentTests.fsproj | 2 +- 3 files changed, 46 insertions(+), 59 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/DelegateDefinition.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/DelegateDefinition.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/DelegateDefinition.fs new file mode 100644 index 00000000000..7851f0c5a1c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/DelegateDefinition.fs @@ -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 = + + [] + let ``Delegate definition with primary constructor and argument.`` () = + FSharp + """ +namespace FSharpTest + type T(x: int) = + delegate of int -> int + """ + |> compile + |> shouldFail + |> withErrorCode 3524 + |> withErrorMessage "No argument are allowed in delegate primary constructor." + + [] + let ``Delegate definition with primary constructor no argument.`` () = + FSharp + """ +namespace FSharpTest + type T() = + delegate of int -> int + """ + |> compile + |> shouldFail + |> withErrorCode 3524 + |> withErrorMessage "No argument are allowed in delegate primary constructor." + + [] + let ``Delegate definition`` () = + FSharp + """ +namespace FSharpTest + type T = + delegate of int -> int + """ + |> compile + |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs deleted file mode 100644 index 4dba28df811..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/InvalidDelegateDefinition.fs +++ /dev/null @@ -1,58 +0,0 @@ -// 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 InvalidDelegateDefinition = - -// [] -// let ``FSX Delegate primary constructor with argument.`` () = -// Fsx -// """ -//namespace FSharpTest -// type T(x: int) = -// delegate of int -> int -// """ -// |> asExe -// |> compileExeAndRun -// |> shouldFail -// |> withErrorCode 3524 -// |> withErrorMessage "No argument are allowed in delegate primary constructor." -// -// [] -// let ``FSX Delegate primary constructor with no argument.`` () = -// Fsx -// """ -//namespace FSharpTest -// type T() = -// delegate of int -> int -// """ -// |> asExe -// |> compileExeAndRun -// |> shouldSucceed -// - [] - let ``FSharp Delegate primary constructor with argument.`` () = - FSharp - """ -namespace FSharpTest - type T(x: int) = - delegate of int -> int - """ - |> compile - |> shouldFail - |> withErrorCode 3524 - |> withErrorMessage "No argument are allowed in delegate primary constructor." - - [] - let ``FSharp Delegate primary constructor with no argument`` () = - FSharp - """ -namespace FSharpTest - type T() = - delegate of int -> int - """ - |> compile - |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 570cb4545a7..f9d08d98f2a 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -93,7 +93,7 @@ - + From f190952a76eb6a02972fa29616dd2e05144399b3 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 26 May 2022 22:46:48 -0700 Subject: [PATCH 09/15] Add BaseLine test --- .../Conformance/DelegateTypes/invalid_delegate_definition.fs | 2 ++ .../DelegateTypes/invalid_delegate_definition.fs.err.bsl | 1 + .../FSharp.Compiler.ComponentTests.fsproj | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs new file mode 100644 index 00000000000..22b9d3f2668 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs @@ -0,0 +1,2 @@ +type T(x: int) = + delegate of int -> int \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl new file mode 100644 index 00000000000..35e438c88b6 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl @@ -0,0 +1 @@ +invalid_delegate_definition.fs (1,6)-(1,15) No argument are allowed in delegate primary constructor. diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index f9d08d98f2a..60899840d4e 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -38,6 +38,7 @@ + @@ -93,7 +94,6 @@ - From 9c7023100aa344d63f05adcf5c19510c2624b84a Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Fri, 27 May 2022 23:39:16 -1100 Subject: [PATCH 10/15] Fix PR comments --- src/Compiler/Checking/CheckDeclarations.fs | 9 ++++----- .../DelegateTypes/invalid_delegate_definition.fs.err.bsl | 1 - ...e_definition.fs => invalid_delegate_definition_01.fs} | 0 .../invalid_delegate_definition_01.fs.err.bsl | 1 + .../DelegateTypes/invalid_delegate_definition_02.fs | 2 ++ .../invalid_delegate_definition_02.fs.err.bsl | 1 + 6 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl rename tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/{invalid_delegate_definition.fs => invalid_delegate_definition_01.fs} (100%) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_01.fs.err.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs.err.bsl diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 1f96fb0bff2..f38ff03e0cc 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -3986,13 +3986,12 @@ module EstablishTypeDefinitionCores = | rf :: _ -> errorR (Error(FSComp.SR.tcInterfaceTypesAndDelegatesCannotContainFields(), rf.Range)) | _ -> () - let primaryConstructorInDelegateCheck(tyCon: Tycon, implicitCtorSynPats : SynSimplePats option) = + let primaryConstructorInDelegateCheck(implicitCtorSynPats : SynSimplePats option) = match implicitCtorSynPats with | None -> () | Some spats -> - if tyCon.IsFSharpDelegateTycon then - let ctorArgNames, _ = TcSimplePatsOfUnknownType cenv true CheckCxs envinner tpenv spats - if not ctorArgNames.IsEmpty then errorR (Error(FSComp.SR.noArgumentsAreAllowedInDelegatePrimaryConstructor(), m)) + let ctorArgNames, _ = TcSimplePatsOfUnknownType cenv true CheckCxs envinner tpenv spats + if not ctorArgNames.IsEmpty then errorR (Error(FSComp.SR.noArgumentsAreAllowedInDelegatePrimaryConstructor(), m)) let envinner = AddDeclaredTypars CheckForDuplicateTypars (tycon.Typars m) envinner let envinner = MakeInnerEnvForTyconRef envinner thisTyconRef false @@ -4189,7 +4188,7 @@ module EstablishTypeDefinitionCores = noAllowNullLiteralAttributeCheck() noAbstractClassAttributeCheck() noFieldsCheck userFields - primaryConstructorInDelegateCheck(tycon, implicitCtorSynPats) + 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)) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl deleted file mode 100644 index 35e438c88b6..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl +++ /dev/null @@ -1 +0,0 @@ -invalid_delegate_definition.fs (1,6)-(1,15) No argument are allowed in delegate primary constructor. diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_01.fs similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs rename to tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_01.fs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_01.fs.err.bsl b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_01.fs.err.bsl new file mode 100644 index 00000000000..e2a293ea0ca --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_01.fs.err.bsl @@ -0,0 +1 @@ +invalid_delegate_definition_01.fs (1,6)-(1,15) No argument are allowed in delegate primary constructor. diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs new file mode 100644 index 00000000000..3363b8f1466 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs @@ -0,0 +1,2 @@ +type T() = + delegate of int -> int \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs.err.bsl b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs.err.bsl new file mode 100644 index 00000000000..5b7a772c34b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs.err.bsl @@ -0,0 +1 @@ +invalid_delegate_definition_02.fs (1,6)-(1,9) No argument are allowed in delegate primary constructor. From 6231d13849eb8db3f442960889e23a25badb48c6 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 28 May 2022 09:01:16 -1100 Subject: [PATCH 11/15] Update net06.fs baseline tests --- tests/fsharp/typecheck/sigs/neg06.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fsharp/typecheck/sigs/neg06.fs b/tests/fsharp/typecheck/sigs/neg06.fs index a31bbbba21c..ee9ddce60dc 100644 --- a/tests/fsharp/typecheck/sigs/neg06.fs +++ b/tests/fsharp/typecheck/sigs/neg06.fs @@ -24,7 +24,7 @@ type BadSealedInterface = type BadSealedAbbreviatedType = System.Object [] -type UnnecessarilySealedDelegate() = delegate of int -> int +type UnnecessarilySealedDelegate = delegate of int -> int type BadExtensionOfSealedType() = class From b5c1b447b3a6fadbae8e9d2f3012f0170bbec780 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 28 May 2022 09:02:08 -1100 Subject: [PATCH 12/15] Simplify the invalid_delegate_definition.err.bsl --- ...elegate_definition_01.fs => invalid_delegate_definition.fs} | 3 +++ .../DelegateTypes/invalid_delegate_definition.fs.err.bsl | 3 +++ .../DelegateTypes/invalid_delegate_definition_01.fs.err.bsl | 1 - .../DelegateTypes/invalid_delegate_definition_02.fs | 2 -- .../DelegateTypes/invalid_delegate_definition_02.fs.err.bsl | 1 - 5 files changed, 6 insertions(+), 4 deletions(-) rename tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/{invalid_delegate_definition_01.fs => invalid_delegate_definition.fs} (54%) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_01.fs.err.bsl delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs.err.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs similarity index 54% rename from tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_01.fs rename to tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs index 22b9d3f2668..dd55759ff61 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_01.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs @@ -1,2 +1,5 @@ type T(x: int) = + delegate of int -> int + +type T() = delegate of int -> int \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl new file mode 100644 index 00000000000..7a647c38557 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl @@ -0,0 +1,3 @@ +invalid_delegate_definition.fs (1,6)-(1,15) No argument are allowed in delegate primary constructor. +invalid_delegate_definition.fs (4,6)-(1,9) No argument are allowed in delegate primary constructor. + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_01.fs.err.bsl b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_01.fs.err.bsl deleted file mode 100644 index e2a293ea0ca..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_01.fs.err.bsl +++ /dev/null @@ -1 +0,0 @@ -invalid_delegate_definition_01.fs (1,6)-(1,15) No argument are allowed in delegate primary constructor. diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs deleted file mode 100644 index 3363b8f1466..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs +++ /dev/null @@ -1,2 +0,0 @@ -type T() = - delegate of int -> int \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs.err.bsl b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs.err.bsl deleted file mode 100644 index 5b7a772c34b..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition_02.fs.err.bsl +++ /dev/null @@ -1 +0,0 @@ -invalid_delegate_definition_02.fs (1,6)-(1,9) No argument are allowed in delegate primary constructor. From 9379742f780f5e34193cb88e5d9246b53c8a170c Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 28 May 2022 12:52:52 -1100 Subject: [PATCH 13/15] Reuse FS0552 error message to avoid having to create a new one --- src/Compiler/FSComp.txt | 3 +-- src/Compiler/xlf/FSComp.txt.cs.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.de.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.es.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.fr.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.it.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.ja.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.ko.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.pl.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.ru.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.tr.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 ----- 14 files changed, 1 insertion(+), 67 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 21d1bad32ab..d59eaf4ff53 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1643,5 +1643,4 @@ reprStateMachineInvalidForm,"The state machine has an unexpected form" 3520,invalidXmlDocPosition,"XML comment is not placed on a valid language element." 3521,tcInvalidMemberDeclNameMissingOrHasParen,"Invalid member declaration. The name of the member is missing or has parentheses." 3522,tcAnonRecdDuplicateFieldId,"The field '%s' appears multiple times in this record expression." -3523,tcAnonRecdTypeDuplicateFieldId,"The field '%s' appears multiple times in this anonymous record type." -3524,noArgumentsAreAllowedInDelegatePrimaryConstructor,"No argument are allowed in delegate primary constructor." +3523,tcAnonRecdTypeDuplicateFieldId,"The field '%s' appears multiple times in this anonymous record type." \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 24de986026f..92860a2902f 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -412,11 +412,6 @@ Hlavička zdroje začínající na posunu {0} má chybný formát. - - No argument are allowed in delegate primary constructor. - No argument are allowed in delegate primary constructor. - - This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Tento výraz není funkcí a nedá se použít. Nechtěli jste získat k indexeru přístup přes expr[index]? diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index b51ec6f178d..22bd16c63c3 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -412,11 +412,6 @@ Der Ressourcenheader, der am Offset {0} beginnt, ist fehlerhaft formatiert. - - No argument are allowed in delegate primary constructor. - No argument are allowed in delegate primary constructor. - - This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Dieser Ausdruck ist keine Funktion und kann nicht angewendet werden. Wollten Sie auf den Indexer stattdessen über "expr[index]" zugreifen? diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 8d35ed0396c..4dc904402bf 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -412,11 +412,6 @@ El encabezado de los recursos que comienza en el desplazamiento {0} está mal formado. - - No argument are allowed in delegate primary constructor. - No argument are allowed in delegate primary constructor. - - This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Esta expresión no es una función y no se puede aplicar. ¿Quería acceder al indexador a través de "expr[index]"? diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 31765f13f7b..0c131e6353c 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -412,11 +412,6 @@ L'en-tête de ressource commençant au décalage {0} est mal formé. - - No argument are allowed in delegate primary constructor. - No argument are allowed in delegate primary constructor. - - This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Cette expression n'est pas une fonction et ne peut pas être appliquée. Souhaitiez-vous accéder à l'indexeur via « expr[index] »? diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 307189f43fc..5a6035a7014 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -412,11 +412,6 @@ L'intestazione di risorsa che inizia a partire dall'offset {0} non è valida. - - No argument are allowed in delegate primary constructor. - No argument are allowed in delegate primary constructor. - - This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Questa espressione non è una funzione e non può essere applicata. Si intendeva accedere all'indicizzatore tramite la sintassi 'expr[index]'? diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 075512ede91..d8f1be72618 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -412,11 +412,6 @@ オフセット {0} で始まるリソース ヘッダーの形式に誤りがあります。 - - No argument are allowed in delegate primary constructor. - No argument are allowed in delegate primary constructor. - - This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? この式は関数ではないため、適用できません。'expr[index]' によってインデクサーにアクセスしようとしましたか? diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 499b2989c92..0cd7929d6ff 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -412,11 +412,6 @@ 오프셋 {0}에서 시작하는 리소스 헤더의 형식이 잘못되었습니다. - - No argument are allowed in delegate primary constructor. - No argument are allowed in delegate primary constructor. - - This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? 이 식은 함수가 아니며 적용할 수 없습니다. 'expr[index]'를 통해 인덱서에 액세스하려고 했습니까? diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index be79c1c05d2..f92eed64abc 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -412,11 +412,6 @@ Nagłówek zasobu rozpoczynający się od przesunięcia {0} jest nieprawidłowo sformułowany. - - No argument are allowed in delegate primary constructor. - No argument are allowed in delegate primary constructor. - - This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? To wyrażenie nie jest funkcją i nie można go zastosować. Spróbuj uzyskać dostęp do indeksatora za pośrednictwem wyrażenia „expr[index]”? diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index ebc86db2b73..0c6ceac112a 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -412,11 +412,6 @@ O cabeçalho do recurso que começa no deslocamento {0} está malformado. - - No argument are allowed in delegate primary constructor. - No argument are allowed in delegate primary constructor. - - This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Essa expressão não é uma função e não pode ser aplicada. Você pretendia acessar o indexador por meio do 'expr[index]'? diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index c6210dc58bc..22b93f16437 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -412,11 +412,6 @@ Заголовок ресурса некорректен начиная со смещения {0}. - - No argument are allowed in delegate primary constructor. - No argument are allowed in delegate primary constructor. - - This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Это выражение не является функцией, и применить его невозможно. Вы хотели обратиться к индексатору с помощью "expr[index]"? diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 0e04faa4dbc..3a720bf0f0d 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -412,11 +412,6 @@ {0} uzaklığında başlayan kaynak üst bilgisi hatalı biçimlendirilmiş. - - No argument are allowed in delegate primary constructor. - No argument are allowed in delegate primary constructor. - - This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? Bu ifade bir fonksiyon değildir ve uygulanamaz. Dizin oluşturucuya “expr[index]” aracılığıyla mı erişmeyi düşündünüz? diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 0d669ac4fa7..f9eea243b93 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -412,11 +412,6 @@ 以偏移量 {0} 开始的资源标头格式不正确。 - - No argument are allowed in delegate primary constructor. - No argument are allowed in delegate primary constructor. - - This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? 此表达式不是函数,无法应用。是否曾打算通过 expr[index] 访问索引器? diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 7c0aa1c60e8..d05d8005fea 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -412,11 +412,6 @@ 從位移 {0} 開始的資源標頭格式錯誤。 - - No argument are allowed in delegate primary constructor. - No argument are allowed in delegate primary constructor. - - This expression is not a function and cannot be applied. Did you intend to access the indexer via 'expr[index]'? 此運算式並非函式,因而無法套用。您要用 'expr[index]' 存取索引子嗎? From 8225846a8b4dffa23e38db8c494e2c93b25ba210 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Sat, 28 May 2022 12:55:33 -1100 Subject: [PATCH 14/15] Update unit tests to match the error message --- src/Compiler/Checking/CheckDeclarations.fs | 2 +- .../Conformance/DelegateTypes/DelegateDefinition.fs | 8 ++++---- .../DelegateTypes/invalid_delegate_definition.fs.err.bsl | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index f38ff03e0cc..59548d96e06 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -3991,7 +3991,7 @@ module EstablishTypeDefinitionCores = | None -> () | Some spats -> let ctorArgNames, _ = TcSimplePatsOfUnknownType cenv true CheckCxs envinner tpenv spats - if not ctorArgNames.IsEmpty then errorR (Error(FSComp.SR.noArgumentsAreAllowedInDelegatePrimaryConstructor(), m)) + 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 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/DelegateDefinition.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/DelegateDefinition.fs index 7851f0c5a1c..df0857b3f28 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/DelegateDefinition.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/DelegateDefinition.fs @@ -17,8 +17,8 @@ namespace FSharpTest """ |> compile |> shouldFail - |> withErrorCode 3524 - |> withErrorMessage "No argument are allowed in delegate primary constructor." + |> withErrorCode 552 + |> withErrorMessage "Only class types may take value arguments" [] let ``Delegate definition with primary constructor no argument.`` () = @@ -30,8 +30,8 @@ namespace FSharpTest """ |> compile |> shouldFail - |> withErrorCode 3524 - |> withErrorMessage "No argument are allowed in delegate primary constructor." + |> withErrorCode 552 + |> withErrorMessage "Only class types may take value arguments" [] let ``Delegate definition`` () = diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl index 7a647c38557..c804d430211 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DelegateTypes/invalid_delegate_definition.fs.err.bsl @@ -1,3 +1,3 @@ -invalid_delegate_definition.fs (1,6)-(1,15) No argument are allowed in delegate primary constructor. -invalid_delegate_definition.fs (4,6)-(1,9) No argument are allowed in delegate primary constructor. +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 From d903a92108d8f793b7cf6a03e3eadec7760ea0bd Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 30 May 2022 04:50:15 -1100 Subject: [PATCH 15/15] Update DEVGUIDE.md Co-authored-by: Vlad Zarytovskii --- DEVGUIDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEVGUIDE.md b/DEVGUIDE.md index 2be5ae6cef5..4cac14d45f3 100644 --- a/DEVGUIDE.md +++ b/DEVGUIDE.md @@ -131,7 +131,7 @@ dotnet build src\Compiler /t:UpdateXlf If you are on a Mac, you can run this command from the root of the repository: ```shell -sudo sh build.sh -c Release +sh build.sh -c Release ``` ## Updating baselines in tests