From f43740f6aab39092b05174a83e3fb6f62f625dff Mon Sep 17 00:00:00 2001 From: kerams Date: Thu, 15 Jun 2023 19:10:28 +0200 Subject: [PATCH 01/12] Support constraint intersection syntax --- src/Compiler/Checking/CheckExpressions.fs | 30 +++++++++ .../GraphChecking/FileContentMapping.fs | 3 + src/Compiler/FSComp.txt | 4 +- src/Compiler/Facilities/LanguageFeatures.fs | 3 + src/Compiler/Facilities/LanguageFeatures.fsi | 1 + src/Compiler/Service/ServiceParseTreeWalk.fs | 1 + src/Compiler/Service/ServiceParsedInputOps.fs | 2 + src/Compiler/SyntaxTree/LexFilter.fs | 2 +- src/Compiler/SyntaxTree/SyntaxTree.fs | 3 + src/Compiler/SyntaxTree/SyntaxTree.fsi | 5 ++ src/Compiler/pars.fsy | 21 +++++++ src/Compiler/xlf/FSComp.txt.cs.xlf | 10 +++ src/Compiler/xlf/FSComp.txt.de.xlf | 10 +++ src/Compiler/xlf/FSComp.txt.es.xlf | 10 +++ src/Compiler/xlf/FSComp.txt.fr.xlf | 10 +++ src/Compiler/xlf/FSComp.txt.it.xlf | 10 +++ src/Compiler/xlf/FSComp.txt.ja.xlf | 10 +++ src/Compiler/xlf/FSComp.txt.ko.xlf | 10 +++ src/Compiler/xlf/FSComp.txt.pl.xlf | 10 +++ src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 10 +++ src/Compiler/xlf/FSComp.txt.ru.xlf | 10 +++ src/Compiler/xlf/FSComp.txt.tr.xlf | 10 +++ src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 10 +++ src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 10 +++ .../FSharp.Compiler.ComponentTests.fsproj | 1 + .../Language/ConstraintIntersectionTests.fs | 62 +++++++++++++++++++ ...ervice.SurfaceArea.netstandard20.debug.bsl | 11 ++++ ...vice.SurfaceArea.netstandard20.release.bsl | 11 ++++ .../SynType/Constraint intersection 01.fs | 3 + .../SynType/Constraint intersection 01.fs.bsl | 56 +++++++++++++++++ .../SynType/Constraint intersection 02.fs | 3 + .../SynType/Constraint intersection 02.fs.bsl | 41 ++++++++++++ .../SynType/Constraint intersection 03.fs | 4 ++ .../SynType/Constraint intersection 03.fs.bsl | 61 ++++++++++++++++++ 34 files changed, 456 insertions(+), 2 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs create mode 100644 tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs create mode 100644 tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs.bsl create mode 100644 tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs create mode 100644 tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs.bsl create mode 100644 tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs create mode 100644 tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs.bsl diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index f18525f47f2..26de60abbce 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -4377,6 +4377,9 @@ and TcTypeOrMeasure kindOpt (cenv: cenv) newOk checkConstraints occ (iwsam: Warn | SynType.HashConstraint(synInnerTy, m) -> TcTypeHashConstraint cenv env newOk checkConstraints occ tpenv synInnerTy m + | SynType.Intersection (synTypar, types, m) -> + TcIntersectionConstraint cenv env newOk checkConstraints occ tpenv synTypar types m + | SynType.StaticConstant (synConst, m) -> TcTypeStaticConstant kindOpt tpenv synConst m @@ -4562,6 +4565,33 @@ and TcTypeHashConstraint (cenv: cenv) env newOk checkConstraints occ tpenv synTy AddCxTypeMustSubsumeType ContextInfo.NoContext env.DisplayEnv cenv.css m NoTrace ty (mkTyparTy tp) tp.AsType, tpenv +// (x: 't & #I1 & #I2) +// (x: #I1 & #I2) +and TcIntersectionConstraint (cenv: cenv) env newOk checkConstraints occ tpenv synTypar synTys m = + checkLanguageFeatureAndRecover cenv.g.langVersion LanguageFeature.ConstraintIntersectionOnFlexibleTypes m + + let tp, tpenv = + match synTypar with + | Some synTypar -> TcTypeOrMeasureParameter (Some TyparKind.Type) cenv env newOk tpenv synTypar + | _ -> TcAnonTypeOrMeasure (Some TyparKind.Type) cenv TyparRigidity.WarnIfNotRigid TyparDynamicReq.Yes newOk m, tpenv + + let typarTy = mkTyparTy tp + + let tpenv = + synTys + |> List.fold (fun tpenv ty -> + match ty with + | SynType.HashConstraint (ty, m) -> + let ty, tpenv = TcTypeAndRecover cenv newOk checkConstraints occ WarnOnIWSAM.No env tpenv ty + AddCxTypeMustSubsumeType ContextInfo.NoContext env.DisplayEnv cenv.css m NoTrace ty typarTy + tpenv + | _ -> + errorR(Error(FSComp.SR.tcConstraintIntersectionSyntaxUsedWithNonFlexibleType(), ty.Range)) + tpenv + ) tpenv + + tp.AsType, tpenv + and TcTypeStaticConstant kindOpt tpenv c m = match c, kindOpt with | _, Some TyparKind.Type -> diff --git a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs index b0b44e941fb..8f3da5a4a49 100644 --- a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs +++ b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs @@ -261,6 +261,9 @@ let visitSynType (t: SynType) : FileContentEntry list = let continuations = List.map visit [ lhsType; rhsType ] Continuation.concatenate continuations continuation | SynType.FromParseError _ -> continuation [] + | SynType.Intersection (types = types) -> + let continuations = List.map visit types + Continuation.concatenate continuations continuation visit t id diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 6aa808c45aa..d43d4797eca 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1575,6 +1575,7 @@ featureExtendedStringInterpolation,"Extended string interpolation similar to C# featureWarningWhenMultipleRecdTypeChoice,"Raises warnings when multiple record type matches were found during name resolution because of overlapping field names." featureImprovedImpliedArgumentNames,"Improved implied argument names" featureStrictIndentation,"Raises errors on incorrect indentation, allows better recovery and analysis during editing" +featureConstraintIntersectionOnFlexibleTypes,"Constraint intersection on flexible types" 3353,fsiInvalidDirective,"Invalid directive '#%s %s'" 3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." @@ -1697,4 +1698,5 @@ featureEscapeBracesInFormattableString,"Escapes curly braces before calling Form 3565,parsExpectingType,"Expecting type" featureInformationalObjInferenceDiagnostic,"Diagnostic 3559 (warn when obj inferred) at informational level, off by default" 3566,tcMultipleRecdTypeChoice,"Multiple type matches were found:\n%s\nThe type '%s' was used. Due to the overlapping field names\n%s\nconsider using type annotations or change the order of open statements." -3567,parsMissingMemberBody,"Expecting member body" \ No newline at end of file +3567,parsMissingMemberBody,"Expecting member body" +3568,tcConstraintIntersectionSyntaxUsedWithNonFlexibleType,"Constraint intersection syntax may only be used with flexible types." \ No newline at end of file diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 9c44cf332b2..23e30db1bb7 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -71,6 +71,7 @@ type LanguageFeature = | WarningWhenMultipleRecdTypeChoice | ImprovedImpliedArgumentNames | DiagnosticForObjInference + | ConstraintIntersectionOnFlexibleTypes /// LanguageVersion management type LanguageVersion(versionText) = @@ -165,6 +166,7 @@ type LanguageVersion(versionText) = LanguageFeature.ImprovedImpliedArgumentNames, previewVersion LanguageFeature.DiagnosticForObjInference, previewVersion LanguageFeature.StrictIndentation, previewVersion + LanguageFeature.ConstraintIntersectionOnFlexibleTypes, previewVersion ] @@ -291,6 +293,7 @@ type LanguageVersion(versionText) = | LanguageFeature.ImprovedImpliedArgumentNames -> FSComp.SR.featureImprovedImpliedArgumentNames () | LanguageFeature.DiagnosticForObjInference -> FSComp.SR.featureInformationalObjInferenceDiagnostic () | LanguageFeature.StrictIndentation -> FSComp.SR.featureStrictIndentation () + | LanguageFeature.ConstraintIntersectionOnFlexibleTypes -> FSComp.SR.featureConstraintIntersectionOnFlexibleTypes () /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 4f124a3324c..13f8edccbad 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -61,6 +61,7 @@ type LanguageFeature = | WarningWhenMultipleRecdTypeChoice | ImprovedImpliedArgumentNames | DiagnosticForObjInference + |ConstraintIntersectionOnFlexibleTypes /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/Service/ServiceParseTreeWalk.fs b/src/Compiler/Service/ServiceParseTreeWalk.fs index b6f95d66a30..3242a4e9f85 100644 --- a/src/Compiler/Service/ServiceParseTreeWalk.fs +++ b/src/Compiler/Service/ServiceParseTreeWalk.fs @@ -844,6 +844,7 @@ module SyntaxTraversal = | SynType.StaticConstantExpr (expr, _) -> traverseSynExpr [] expr | SynType.Paren (innerType = t) | SynType.SignatureParameter (usedType = t) -> traverseSynType path t + | SynType.Intersection (types = types) -> List.tryPick (traverseSynType path) types | SynType.Anon _ | SynType.AnonRecd _ | SynType.LongIdent _ diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index a0f8a810ccb..bbd4ee275be 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -681,6 +681,7 @@ module ParsedInput = | SynType.SignatureParameter (usedType = t) -> walkType t | SynType.StaticConstantExpr (e, _) -> walkExpr e | SynType.StaticConstantNamed (ident, value, _) -> List.tryPick walkType [ ident; value ] + | SynType.Intersection (types = types) -> List.tryPick walkType types | SynType.Anon _ | SynType.AnonRecd _ | SynType.LongIdent _ @@ -1699,6 +1700,7 @@ module ParsedInput = | SynType.StaticConstantNamed (ident, value, _) -> walkType ident walkType value + | SynType.Intersection (types = types) -> List.iter walkType types | SynType.Anon _ | SynType.AnonRecd _ | SynType.Var _ diff --git a/src/Compiler/SyntaxTree/LexFilter.fs b/src/Compiler/SyntaxTree/LexFilter.fs index c90539ad3f8..d2b201e1607 100644 --- a/src/Compiler/SyntaxTree/LexFilter.fs +++ b/src/Compiler/SyntaxTree/LexFilter.fs @@ -1117,7 +1117,7 @@ type LexFilterImpl ( // f<{| C : int |}>x // fx // fx - | DEFAULT | COLON | COLON_GREATER | STRUCT | NULL | DELEGATE | AND | WHEN + | DEFAULT | COLON | COLON_GREATER | STRUCT | NULL | DELEGATE | AND | WHEN | AMP | DOT_DOT | NEW | LBRACE_BAR diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index e9eb8bdfac3..9368d8e8283 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -443,6 +443,8 @@ type SynType = | FromParseError of range: range + | Intersection of typar: SynTypar option * types: SynType list * range: range + member x.Range = match x with | SynType.App (range = m) @@ -462,6 +464,7 @@ type SynType = | SynType.Paren (range = m) | SynType.SignatureParameter (range = m) | SynType.Or (range = m) + | SynType.Intersection (range = m) | SynType.FromParseError (range = m) -> m | SynType.LongIdent lidwd -> lidwd.Range diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index d7f01cd4889..f6907fff653 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -521,6 +521,11 @@ type SynType = /// A type arising from a parse error | FromParseError of range: range + /// F# syntax: x: #I1 & #I2 + /// F# syntax: x: 't & #I1 & #I2 + /// Shorthand for x: 't when 't :> I1 and 't :> I2 + | Intersection of typar: SynTypar option * types: SynType list * range: range + /// Gets the syntax range of this construct member Range: range diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index c65fd54b1d4..8c2ce253065 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -2367,6 +2367,15 @@ typeConstraints: | typeConstraint { [$1] } +/* Any tokens in this grammar must be added to the lex filter rule 'peekAdjacentTypars' */ +/* See the F# specification "Lexical analysis of type applications and type parameter definitions" */ +intersectionConstraints: + | intersectionConstraints AMP atomType %prec prec_no_more_attr_bindings // todo precedence + { $3 :: $1 } + + | atomType + { [ $1 ] } + /* Any tokens in this grammar must be added to the lex filter rule 'peekAdjacentTypars' */ /* See the F# specification "Lexical analysis of type applications and type parameter definitions" */ typeConstraint: @@ -5653,6 +5662,15 @@ tupleOrQuotTypeElements: | appType %prec prec_tuptyptail_prefix { [ SynTupleTypeSegment.Type $1 ] } +/* Any tokens in this grammar must be added to the lex filter rule 'peekAdjacentTypars' */ +/* See the F# specification "Lexical analysis of type applications and type parameter definitions" */ +intersectionType: + | typar AMP intersectionConstraints %prec prec_no_more_attr_bindings // todo precedence + { SynType.Intersection(Some $1, $3, lhs parseState) } + + | atomType AMP intersectionConstraints %prec prec_no_more_attr_bindings // todo precedence + { SynType.Intersection(None, $1 :: $3, lhs parseState) } + appTypeCon: | path %prec prec_atomtyp_path { SynType.LongIdent($1) } @@ -5691,6 +5709,9 @@ appType: | powerType { $1 } + | intersectionType + { $1 } + | typar COLON_GREATER typ { let tp, typ = $1, $3 let m = lhs parseState diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 6e2ca9b5231..9ef00dc14f8 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -207,6 +207,11 @@ Povolit implicitní atribut Extension pro deklarující typy, moduly + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption využití člena výchozího rozhraní @@ -982,6 +987,11 @@ Atributy nejde použít pro rozšíření typů. + + Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Tento výraz záznamu kopírování a aktualizace mění všechna pole typu záznamu '{0}'. Zvažte použití syntaxe konstrukce záznamu. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index c7a067332b5..c64fbf37ae8 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -207,6 +207,11 @@ Implizites Erweiterungsattribut für deklarierende Typen und Module zulassen + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption standardmäßige Schnittstellenmembernutzung @@ -982,6 +987,11 @@ Attribute können nicht auf Typerweiterungen angewendet werden. + + Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Dieser Ausdruck zum Kopieren und Aktualisieren von Datensätzen ändert alle Felder des Datensatztyps "{0}". Erwägen Sie stattdessen die Verwendung der Datensatzerstellungssyntax. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 6cdfce98c03..a9d52ece820 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -207,6 +207,11 @@ Permitir atributo Extension implícito en tipos declarativo, módulos + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption consumo de miembros de interfaz predeterminados @@ -982,6 +987,11 @@ Los atributos no se pueden aplicar a las extensiones de tipo. + + Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Esta expresión de copia y actualización de registros cambia todos los campos de tipo de registro "{0}". Es preferible utilizar la sintaxis de construcción de registros. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index f5cc4b1a8fe..b549477b0bd 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -207,6 +207,11 @@ Autoriser l’attribut implicite Extension lors de la déclaration des types, modules + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption consommation par défaut des membres d'interface @@ -982,6 +987,11 @@ Impossible d'appliquer des attributs aux extensions de type. + + Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Cette expression d'enregistrement de copie et de mise à jour modifie tous les champs du type d'enregistrement '{0}'. Envisagez d'utiliser la syntaxe de construction d'enregistrement à la place. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index e4a1a9a2d44..47cc7355f5b 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -207,6 +207,11 @@ Consentire l'attributo estensione implicito per i tipi dichiarabili, i moduli + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption utilizzo predefinito dei membri di interfaccia @@ -982,6 +987,11 @@ Gli attributi non possono essere applicati a estensioni di tipo. + + Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Questa espressione di record di copia e aggiornamento modifica tutti i campi del tipo di record '{0}'. Provare a usare la sintassi di costruzione dei record. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 0508471758d..413a66532ee 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -207,6 +207,11 @@ 型、モジュールの宣言で暗黙的な拡張属性を許可する + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption 既定のインターフェイス メンバーの消費 @@ -982,6 +987,11 @@ 属性を型拡張に適用することはできません。 + + Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. この copy-and-update レコード式は、レコードの種類が '{0}' であるすべてのフィールドを変更します。代わりにレコード構築構文を使用することを検討してください。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index e98bb588acc..8c21e076c6e 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -207,6 +207,11 @@ 유형, 모듈 선언에 암시적 확장 속성 허용 + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption 기본 인터페이스 멤버 사용 @@ -982,6 +987,11 @@ 형식 확장에 특성을 적용할 수 없습니다. + + Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. 이 레코드 복사 및 업데이트 식은 '{0}' 레코드 형식의 모든 필드를 변경합니다. 레코드 생성 구문을 대신 사용하는 것이 좋습니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index bf8459b7db8..60833723f53 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -207,6 +207,11 @@ Zezwalaj na niejawny atrybut Rozszerzenie dla deklarujących typów, modułów + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption domyślne użycie składowej interfejsu @@ -982,6 +987,11 @@ Atrybutów nie można stosować do rozszerzeń typu. + + Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. To wyrażenie rekordu kopiowania i aktualizacji zmienia wszystkie pola typu rekordu „{0}”. Zamiast tego rozważ użycie składni konstrukcji rekordu. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 0deccc83bdd..a6d4854e779 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -207,6 +207,11 @@ Permitir atributo de Extensão implícito em tipos declarativos, módulos + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption consumo de membro da interface padrão @@ -982,6 +987,11 @@ Os atributos não podem ser aplicados às extensões de tipo. + + Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Essa expressão de registro copiar e atualizar altera todos os campos do tipo de registro '{0}'. Considere usar a sintaxe de construção de registro em vez disso. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 82806d6d1b9..27f7f3389b9 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -207,6 +207,11 @@ Разрешить атрибут неявного расширения для объявляющих типов, модулей + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption использование элемента интерфейса по умолчанию @@ -982,6 +987,11 @@ Атрибуты не могут быть применены к расширениям типа. + + Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Это выражение записи копирования и обновления изменяет все поля типа записи "{0}". Вместо этого можно использовать синтаксис конструкции записи. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index c106b39622a..98c9f7f033a 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -207,6 +207,11 @@ Türler, modüller bildirirken örtük Extension özniteliğine izin ver + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption varsayılan arabirim üyesi tüketimi @@ -982,6 +987,11 @@ Öznitelikler tür uzantılarına uygulanamaz. + + Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Bu kopyalama ve güncelleştirme kayıt ifadesi, '{0}' kayıt türündeki tüm alanları değiştirir. Bunun yerine kayıt oluşturma söz dizimini kullanmayı deneyin. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index c2911c4696d..75cedac984b 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -207,6 +207,11 @@ 允许对声明类型、模块使用隐式扩展属性 + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption 默认接口成员消耗 @@ -982,6 +987,11 @@ 属性不可应用于类型扩展。 + + Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. 此复制和更新记录表达式更改记录类型“{0}”的所有字段。请考虑改用记录构造语法。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index a495354d5b2..04f885edb82 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -207,6 +207,11 @@ 允許宣告類型、模組上的隱含擴充屬性 + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption 預設介面成員使用 @@ -982,6 +987,11 @@ 屬性無法套用到類型延伸模組。 + + Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. 此複製和更新記錄運算式將變更記錄類型為 '{0}' 的所有欄位。請考慮改用記錄建構語法。 diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 93ff861fe68..552f0032d55 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -188,6 +188,7 @@ + diff --git a/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs new file mode 100644 index 00000000000..6ec5655f0c5 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs @@ -0,0 +1,62 @@ +module Language.ConstraintIntersectionTests + +open Xunit +open FSharp.Test.Compiler +open StructuredResultsAsserts + +[] +let ``Constraint intersection works in lang preview``() = + FSharp """ +open System +open System.Threading.Tasks +open System.Collections.Generic + +type I = + abstract g: unit -> unit + abstract h: #IDisposable & #seq -> unit + +type F = + interface I with + member _.g () = () + member _.h v = + for _ in v do + () + v.Dispose () + +type E () = + interface IDisposable with + member _.Dispose () = () + interface IEnumerable with + member _.GetEnumerator () = null: IEnumerator + member _.GetEnumerator () = null: Collections.IEnumerator + +let x (f: 't & #I) = + f.g () + f.h (new E ()) + ResizeArray<'t> () + +let y (f: 't & #I & #IDisposable) = + f.g () + f.Dispose () + ResizeArray<'t> () + +let z (f: #I & #IDisposable & #Task & #seq) = + f.g () + f.Result |> ignore + f.Dispose () + """ + |> withLangVersionPreview + |> typecheck + |> shouldSucceed + +[] +let ``Constraint intersection does not work with non-flexible types``() = + FSharp """ +let y (f: #seq & System.IDisposable) = () + """ + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withDiagnostics [ + Error 3568, Line 2, Col 23, Line 2, Col 41, "Constraint intersection syntax may only be used with flexible types." + ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index a9c06dc1612..28f1fb7c603 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -8435,6 +8435,12 @@ FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Syntax.SynType ge FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Syntax.SynType innerType FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Text.Range range +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.Text.Range get_range() +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.Text.Range range +FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] get_types() +FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] types +FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar] get_typar() +FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar] typar FSharp.Compiler.Syntax.SynType+LongIdent: FSharp.Compiler.Syntax.SynLongIdent get_longDotId() FSharp.Compiler.Syntax.SynType+LongIdent: FSharp.Compiler.Syntax.SynLongIdent longDotId FSharp.Compiler.Syntax.SynType+LongIdentApp: FSharp.Compiler.Syntax.SynLongIdent get_longDotId() @@ -8500,6 +8506,7 @@ FSharp.Compiler.Syntax.SynType+Tags: Int32 Array FSharp.Compiler.Syntax.SynType+Tags: Int32 FromParseError FSharp.Compiler.Syntax.SynType+Tags: Int32 Fun FSharp.Compiler.Syntax.SynType+Tags: Int32 HashConstraint +FSharp.Compiler.Syntax.SynType+Tags: Int32 Intersection FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdent FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdentApp FSharp.Compiler.Syntax.SynType+Tags: Int32 MeasurePower @@ -8535,6 +8542,7 @@ FSharp.Compiler.Syntax.SynType: Boolean IsArray FSharp.Compiler.Syntax.SynType: Boolean IsFromParseError FSharp.Compiler.Syntax.SynType: Boolean IsFun FSharp.Compiler.Syntax.SynType: Boolean IsHashConstraint +FSharp.Compiler.Syntax.SynType: Boolean IsIntersection FSharp.Compiler.Syntax.SynType: Boolean IsLongIdent FSharp.Compiler.Syntax.SynType: Boolean IsLongIdentApp FSharp.Compiler.Syntax.SynType: Boolean IsMeasurePower @@ -8554,6 +8562,7 @@ FSharp.Compiler.Syntax.SynType: Boolean get_IsArray() FSharp.Compiler.Syntax.SynType: Boolean get_IsFromParseError() FSharp.Compiler.Syntax.SynType: Boolean get_IsFun() FSharp.Compiler.Syntax.SynType: Boolean get_IsHashConstraint() +FSharp.Compiler.Syntax.SynType: Boolean get_IsIntersection() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdent() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdentApp() FSharp.Compiler.Syntax.SynType: Boolean get_IsMeasurePower() @@ -8573,6 +8582,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewArray(Int32, F FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFromParseError(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFun(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewHashConstraint(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewIntersection(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdent(FSharp.Compiler.Syntax.SynLongIdent) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdentApp(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynLongIdent, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewMeasurePower(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynRationalConst, FSharp.Compiler.Text.Range) @@ -8592,6 +8602,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Array FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+FromParseError FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Fun FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+HashConstraint +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Intersection FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+LongIdent FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+LongIdentApp FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+MeasurePower diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 1736be3d13e..9dfa59aebb9 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -8435,6 +8435,12 @@ FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Syntax.SynType ge FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Syntax.SynType innerType FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Text.Range range +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.Text.Range get_range() +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.Text.Range range +FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] get_types() +FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] types +FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar] get_typar() +FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar] typar FSharp.Compiler.Syntax.SynType+LongIdent: FSharp.Compiler.Syntax.SynLongIdent get_longDotId() FSharp.Compiler.Syntax.SynType+LongIdent: FSharp.Compiler.Syntax.SynLongIdent longDotId FSharp.Compiler.Syntax.SynType+LongIdentApp: FSharp.Compiler.Syntax.SynLongIdent get_longDotId() @@ -8500,6 +8506,7 @@ FSharp.Compiler.Syntax.SynType+Tags: Int32 Array FSharp.Compiler.Syntax.SynType+Tags: Int32 FromParseError FSharp.Compiler.Syntax.SynType+Tags: Int32 Fun FSharp.Compiler.Syntax.SynType+Tags: Int32 HashConstraint +FSharp.Compiler.Syntax.SynType+Tags: Int32 Intersection FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdent FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdentApp FSharp.Compiler.Syntax.SynType+Tags: Int32 MeasurePower @@ -8535,6 +8542,7 @@ FSharp.Compiler.Syntax.SynType: Boolean IsArray FSharp.Compiler.Syntax.SynType: Boolean IsFromParseError FSharp.Compiler.Syntax.SynType: Boolean IsFun FSharp.Compiler.Syntax.SynType: Boolean IsHashConstraint +FSharp.Compiler.Syntax.SynType: Boolean IsIntersection FSharp.Compiler.Syntax.SynType: Boolean IsLongIdent FSharp.Compiler.Syntax.SynType: Boolean IsLongIdentApp FSharp.Compiler.Syntax.SynType: Boolean IsMeasurePower @@ -8554,6 +8562,7 @@ FSharp.Compiler.Syntax.SynType: Boolean get_IsArray() FSharp.Compiler.Syntax.SynType: Boolean get_IsFromParseError() FSharp.Compiler.Syntax.SynType: Boolean get_IsFun() FSharp.Compiler.Syntax.SynType: Boolean get_IsHashConstraint() +FSharp.Compiler.Syntax.SynType: Boolean get_IsIntersection() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdent() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdentApp() FSharp.Compiler.Syntax.SynType: Boolean get_IsMeasurePower() @@ -8573,6 +8582,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewArray(Int32, F FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFromParseError(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFun(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewHashConstraint(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewIntersection(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdent(FSharp.Compiler.Syntax.SynLongIdent) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdentApp(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynLongIdent, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewMeasurePower(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynRationalConst, FSharp.Compiler.Text.Range) @@ -8592,6 +8602,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Array FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+FromParseError FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Fun FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+HashConstraint +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Intersection FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+LongIdent FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+LongIdentApp FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+MeasurePower diff --git a/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs b/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs new file mode 100644 index 00000000000..ec98ef6e362 --- /dev/null +++ b/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs @@ -0,0 +1,3 @@ +module Module + +let y (f: #I & #Task & #seq) = () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs.bsl b/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs.bsl new file mode 100644 index 00000000000..a3265a7d63f --- /dev/null +++ b/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs.bsl @@ -0,0 +1,56 @@ +ImplFile + (ParsedImplFileInput + ("/root/SynType/Constraint intersection 01.fs", false, + QualifiedNameOfFile Module, [], [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some f)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([y], [], [None]), None, None, + Pats + [Paren + (Typed + (Named + (SynIdent (f, None), false, None, (3,7--3,8)), + Intersection + (None, + [HashConstraint + (LongIdent (SynLongIdent ([I], [], [None])), + (3,10--3,12)); + HashConstraint + (App + (LongIdent + (SynLongIdent ([seq], [], [None])), + Some (3,32--3,33), + [LongIdent + (SynLongIdent ([string], [], [None]))], + [], Some (3,39--3,40), false, + (3,29--3,40)), (3,28--3,40)); + HashConstraint + (App + (LongIdent + (SynLongIdent ([Task], [], [None])), + Some (3,20--3,21), + [LongIdent + (SynLongIdent ([int], [], [None]))], + [], Some (3,24--3,25), false, + (3,16--3,25)), (3,15--3,25))], + (3,10--3,40)), (3,7--3,40)), (3,6--3,41))], + None, (3,4--3,41)), None, Const (Unit, (3,44--3,46)), + (3,4--3,41), NoneAtLet, { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,42--3,43) })], + (3,0--3,46))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--3,46), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs b/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs new file mode 100644 index 00000000000..fc03c536829 --- /dev/null +++ b/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs @@ -0,0 +1,3 @@ +module Module + +let y (f: 't & #I & #IDisposable) = () diff --git a/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs.bsl b/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs.bsl new file mode 100644 index 00000000000..83ad0deabeb --- /dev/null +++ b/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs.bsl @@ -0,0 +1,41 @@ +ImplFile + (ParsedImplFileInput + ("/root/SynType/Constraint intersection 02.fs", false, + QualifiedNameOfFile Module, [], [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some f)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([y], [], [None]), None, None, + Pats + [Paren + (Typed + (Named + (SynIdent (f, None), false, None, (3,7--3,8)), + Intersection + (Some (SynTypar (t, None, false)), + [HashConstraint + (LongIdent + (SynLongIdent ([IDisposable], [], [None])), + (3,20--3,32)); + HashConstraint + (LongIdent (SynLongIdent ([I], [], [None])), + (3,15--3,17))], (3,10--3,32)), (3,7--3,32)), + (3,6--3,33))], None, (3,4--3,33)), None, + Const (Unit, (3,36--3,38)), (3,4--3,33), NoneAtLet, + { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,34--3,35) })], (3,0--3,38))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--3,38), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs b/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs new file mode 100644 index 00000000000..8b050ec48d3 --- /dev/null +++ b/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs @@ -0,0 +1,4 @@ +module Module + +type I = + abstract h: #IDisposable & #seq -> unit \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs.bsl b/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs.bsl new file mode 100644 index 00000000000..5fbcc82c4d5 --- /dev/null +++ b/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs.bsl @@ -0,0 +1,61 @@ +ImplFile + (ParsedImplFileInput + ("/root/SynType/Constraint intersection 03.fs", false, + QualifiedNameOfFile Module, [], [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [I], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (3,5--3,6)), + ObjectModel + (Unspecified, + [AbstractSlot + (SynValSig + ([], SynIdent (h, None), + SynValTyparDecls (None, true), + Fun + (Intersection + (None, + [HashConstraint + (LongIdent + (SynLongIdent + ([IDisposable], [], [None])), + (4,16--4,28)); + HashConstraint + (App + (LongIdent + (SynLongIdent ([seq], [], [None])), + Some (4,35--4,36), + [LongIdent + (SynLongIdent ([int], [], [None]))], + [], Some (4,39--4,40), false, + (4,32--4,40)), (4,31--4,40))], + (4,16--4,40)), + LongIdent (SynLongIdent ([unit], [], [None])), + (4,16--4,48), { ArrowRange = (4,41--4,43) }), + SynValInfo + ([[SynArgInfo ([], false, None)]], + SynArgInfo ([], false, None)), false, false, + PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), + None, None, (4,4--4,48), + { LeadingKeyword = Abstract (4,4--4,12) + InlineKeyword = None + WithKeyword = None + EqualsRange = None }), + { IsInstance = true + IsDispatchSlot = true + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, (4,4--4,48), + { GetSetKeywords = None })], (4,4--4,48)), [], None, + (3,5--4,48), { LeadingKeyword = Type (3,0--3,4) + EqualsRange = Some (3,7--3,8) + WithKeyword = None })], (3,0--4,48))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--4,48), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) From 8fcac3c71b2b81c23b99c5a6cfcd5939decaf649 Mon Sep 17 00:00:00 2001 From: kerams Date: Thu, 15 Jun 2023 19:33:13 +0200 Subject: [PATCH 02/12] Obey Fantomas --- src/Compiler/Facilities/LanguageFeatures.fsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 13f8edccbad..6bf5c9d6891 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -61,7 +61,7 @@ type LanguageFeature = | WarningWhenMultipleRecdTypeChoice | ImprovedImpliedArgumentNames | DiagnosticForObjInference - |ConstraintIntersectionOnFlexibleTypes + | ConstraintIntersectionOnFlexibleTypes /// LanguageVersion management type LanguageVersion = From c23f85a42d65c93c37122a7431f746caaa9d55cf Mon Sep 17 00:00:00 2001 From: kerams Date: Thu, 15 Jun 2023 21:22:44 +0200 Subject: [PATCH 03/12] Adjust wording --- src/Compiler/FSComp.txt | 2 +- src/Compiler/xlf/FSComp.txt.cs.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.de.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.es.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.fr.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.it.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.ja.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.ko.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.pl.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.ru.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.tr.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 4 ++-- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 4 ++-- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index d43d4797eca..3bbfe2c00fc 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1699,4 +1699,4 @@ featureEscapeBracesInFormattableString,"Escapes curly braces before calling Form featureInformationalObjInferenceDiagnostic,"Diagnostic 3559 (warn when obj inferred) at informational level, off by default" 3566,tcMultipleRecdTypeChoice,"Multiple type matches were found:\n%s\nThe type '%s' was used. Due to the overlapping field names\n%s\nconsider using type annotations or change the order of open statements." 3567,parsMissingMemberBody,"Expecting member body" -3568,tcConstraintIntersectionSyntaxUsedWithNonFlexibleType,"Constraint intersection syntax may only be used with flexible types." \ No newline at end of file +3568,tcConstraintIntersectionSyntaxUsedWithNonFlexibleType,"Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." \ 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 9ef00dc14f8..654052533db 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -988,8 +988,8 @@ - Constraint intersection syntax may only be used with flexible types. - Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index c64fbf37ae8..b35a4fc8c66 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -988,8 +988,8 @@ - Constraint intersection syntax may only be used with flexible types. - Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index a9d52ece820..5ad81ff6127 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -988,8 +988,8 @@ - Constraint intersection syntax may only be used with flexible types. - Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index b549477b0bd..7349b75e5ed 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -988,8 +988,8 @@ - Constraint intersection syntax may only be used with flexible types. - Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 47cc7355f5b..d550eaf2149 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -988,8 +988,8 @@ - Constraint intersection syntax may only be used with flexible types. - Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 413a66532ee..11b114a3fed 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -988,8 +988,8 @@ - Constraint intersection syntax may only be used with flexible types. - Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 8c21e076c6e..ec43ee9d83e 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -988,8 +988,8 @@ - Constraint intersection syntax may only be used with flexible types. - Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 60833723f53..8d7e38b73a9 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -988,8 +988,8 @@ - Constraint intersection syntax may only be used with flexible types. - Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index a6d4854e779..b1c250edc59 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -988,8 +988,8 @@ - Constraint intersection syntax may only be used with flexible types. - Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 27f7f3389b9..3c3fc7cea8b 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -988,8 +988,8 @@ - Constraint intersection syntax may only be used with flexible types. - Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 98c9f7f033a..943c0601cd4 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -988,8 +988,8 @@ - Constraint intersection syntax may only be used with flexible types. - Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 75cedac984b..56e1047162c 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -988,8 +988,8 @@ - Constraint intersection syntax may only be used with flexible types. - Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 04f885edb82..9148ad7c70e 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -988,8 +988,8 @@ - Constraint intersection syntax may only be used with flexible types. - Constraint intersection syntax may only be used with flexible types. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. From 3c6025b4931a1e439e056cdf4b0d5f8809d2b3e8 Mon Sep 17 00:00:00 2001 From: kerams Date: Fri, 16 Jun 2023 17:43:49 +0200 Subject: [PATCH 04/12] Add trivia --- src/Compiler/Checking/CheckExpressions.fs | 4 +-- src/Compiler/SyntaxTree/SyntaxTree.fs | 2 +- src/Compiler/SyntaxTree/SyntaxTree.fsi | 2 +- src/Compiler/SyntaxTree/SyntaxTrivia.fs | 3 ++ src/Compiler/SyntaxTree/SyntaxTrivia.fsi | 8 +++++ src/Compiler/pars.fsy | 11 +++--- ...ervice.SurfaceArea.netstandard20.debug.bsl | 8 ++++- ...vice.SurfaceArea.netstandard20.release.bsl | 8 ++++- .../SynType/Constraint intersection 01.fs.bsl | 34 ++++++++++--------- .../SynType/Constraint intersection 02.fs | 2 +- .../SynType/Constraint intersection 02.fs.bsl | 31 ++++++++++++----- .../SynType/Constraint intersection 03.fs | 2 +- .../SynType/Constraint intersection 03.fs.bsl | 22 +++++++----- 13 files changed, 92 insertions(+), 45 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 26de60abbce..799f38d7085 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -4377,8 +4377,8 @@ and TcTypeOrMeasure kindOpt (cenv: cenv) newOk checkConstraints occ (iwsam: Warn | SynType.HashConstraint(synInnerTy, m) -> TcTypeHashConstraint cenv env newOk checkConstraints occ tpenv synInnerTy m - | SynType.Intersection (synTypar, types, m) -> - TcIntersectionConstraint cenv env newOk checkConstraints occ tpenv synTypar types m + | SynType.Intersection (tp, tys, m, _) -> + TcIntersectionConstraint cenv env newOk checkConstraints occ tpenv tp tys m | SynType.StaticConstant (synConst, m) -> TcTypeStaticConstant kindOpt tpenv synConst m diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index 9368d8e8283..f6edb890a86 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -443,7 +443,7 @@ type SynType = | FromParseError of range: range - | Intersection of typar: SynTypar option * types: SynType list * range: range + | Intersection of typar: SynTypar option * types: SynType list * range: range * trivia: SynTypeIntersectionTrivia member x.Range = match x with diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index f6907fff653..1063655fbab 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -524,7 +524,7 @@ type SynType = /// F# syntax: x: #I1 & #I2 /// F# syntax: x: 't & #I1 & #I2 /// Shorthand for x: 't when 't :> I1 and 't :> I2 - | Intersection of typar: SynTypar option * types: SynType list * range: range + | Intersection of typar: SynTypar option * types: SynType list * range: range * trivia: SynTypeIntersectionTrivia /// Gets the syntax range of this construct member Range: range diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fs b/src/Compiler/SyntaxTree/SyntaxTrivia.fs index d5c459b33f5..abe3fa898ba 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fs +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fs @@ -381,3 +381,6 @@ type SynMemberSigMemberTrivia = } static member Zero: SynMemberSigMemberTrivia = { GetSetKeywords = None } + +[] +type SynTypeIntersectionTrivia = { AmpersandRanges: range list } diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi index 1f2d001cfd7..d19f89965ae 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi @@ -501,3 +501,11 @@ type SynMemberSigMemberTrivia = } static member Zero: SynMemberSigMemberTrivia + +/// Represents additional information for SynType.Intersection +[] +type SynTypeIntersectionTrivia = + { + /// The syntax ranges of the `&` tokens + AmpersandRanges: range list + } diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 3c909290ad1..acfa5a30cb2 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -2382,10 +2382,11 @@ typeConstraints: /* See the F# specification "Lexical analysis of type applications and type parameter definitions" */ intersectionConstraints: | intersectionConstraints AMP atomType %prec prec_no_more_attr_bindings // todo precedence - { $3 :: $1 } + { let constraints, mAmpersands = $1 + ($3 :: constraints), (rhs parseState 2 :: mAmpersands) } | atomType - { [ $1 ] } + { [ $1 ], [] } /* Any tokens in this grammar must be added to the lex filter rule 'peekAdjacentTypars' */ /* See the F# specification "Lexical analysis of type applications and type parameter definitions" */ @@ -5677,10 +5678,12 @@ tupleOrQuotTypeElements: /* See the F# specification "Lexical analysis of type applications and type parameter definitions" */ intersectionType: | typar AMP intersectionConstraints %prec prec_no_more_attr_bindings // todo precedence - { SynType.Intersection(Some $1, $3, lhs parseState) } + { let constraints, mAmpersands = $3 + SynType.Intersection(Some $1, List.rev constraints, lhs parseState, { AmpersandRanges = rhs parseState 2 :: List.rev mAmpersands }) } | atomType AMP intersectionConstraints %prec prec_no_more_attr_bindings // todo precedence - { SynType.Intersection(None, $1 :: $3, lhs parseState) } + { let constraints, mAmpersands = $3 + SynType.Intersection(None, $1 :: List.rev constraints, lhs parseState, { AmpersandRanges = rhs parseState 2 :: List.rev mAmpersands }) } appTypeCon: | path %prec prec_atomtyp_path diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index 28f1fb7c603..b39123fc018 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -8435,6 +8435,8 @@ FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Syntax.SynType ge FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Syntax.SynType innerType FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Text.Range range +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia get_trivia() +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia trivia FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] get_types() @@ -8582,7 +8584,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewArray(Int32, F FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFromParseError(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFun(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewHashConstraint(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) -FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewIntersection(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewIntersection(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdent(FSharp.Compiler.Syntax.SynLongIdent) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdentApp(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynLongIdent, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewMeasurePower(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynRationalConst, FSharp.Compiler.Text.Range) @@ -9852,6 +9854,10 @@ FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: FSharp.Compiler.Text.Range ArrowR FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: FSharp.Compiler.Text.Range get_ArrowRange() FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: Void .ctor(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range] AmpersandRanges +FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range] get_AmpersandRanges() +FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia: Void .ctor(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: FSharp.Compiler.Text.Range OrKeyword FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: FSharp.Compiler.Text.Range get_OrKeyword() FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: System.String ToString() diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 9dfa59aebb9..b7a8c358dad 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -8435,6 +8435,8 @@ FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Syntax.SynType ge FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Syntax.SynType innerType FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Text.Range range +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia get_trivia() +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia trivia FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] get_types() @@ -8582,7 +8584,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewArray(Int32, F FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFromParseError(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFun(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewHashConstraint(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) -FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewIntersection(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewIntersection(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdent(FSharp.Compiler.Syntax.SynLongIdent) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdentApp(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynLongIdent, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewMeasurePower(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynRationalConst, FSharp.Compiler.Text.Range) @@ -9852,6 +9854,10 @@ FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: FSharp.Compiler.Text.Range ArrowR FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: FSharp.Compiler.Text.Range get_ArrowRange() FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: Void .ctor(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range] AmpersandRanges +FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range] get_AmpersandRanges() +FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia: Void .ctor(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: FSharp.Compiler.Text.Range OrKeyword FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: FSharp.Compiler.Text.Range get_OrKeyword() FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: System.String ToString() diff --git a/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs.bsl b/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs.bsl index a3265a7d63f..64e8fd7c7a8 100644 --- a/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs.bsl +++ b/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs.bsl @@ -26,15 +26,6 @@ ImplFile [HashConstraint (LongIdent (SynLongIdent ([I], [], [None])), (3,10--3,12)); - HashConstraint - (App - (LongIdent - (SynLongIdent ([seq], [], [None])), - Some (3,32--3,33), - [LongIdent - (SynLongIdent ([string], [], [None]))], - [], Some (3,39--3,40), false, - (3,29--3,40)), (3,28--3,40)); HashConstraint (App (LongIdent @@ -43,13 +34,24 @@ ImplFile [LongIdent (SynLongIdent ([int], [], [None]))], [], Some (3,24--3,25), false, - (3,16--3,25)), (3,15--3,25))], - (3,10--3,40)), (3,7--3,40)), (3,6--3,41))], - None, (3,4--3,41)), None, Const (Unit, (3,44--3,46)), - (3,4--3,41), NoneAtLet, { LeadingKeyword = Let (3,0--3,3) - InlineKeyword = None - EqualsRange = Some (3,42--3,43) })], - (3,0--3,46))], + (3,16--3,25)), (3,15--3,25)); + HashConstraint + (App + (LongIdent + (SynLongIdent ([seq], [], [None])), + Some (3,32--3,33), + [LongIdent + (SynLongIdent ([string], [], [None]))], + [], Some (3,39--3,40), false, + (3,29--3,40)), (3,28--3,40))], + (3,10--3,40), + { AmpersandRanges = + [(3,13--3,14); (3,26--3,27)] }), (3,7--3,40)), + (3,6--3,41))], None, (3,4--3,41)), None, + Const (Unit, (3,44--3,46)), (3,4--3,41), NoneAtLet, + { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,42--3,43) })], (3,0--3,46))], PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, (1,0--3,46), { LeadingKeyword = Module (1,0--1,6) })], (true, true), { ConditionalDirectives = [] diff --git a/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs b/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs index fc03c536829..feb9b50bd06 100644 --- a/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs +++ b/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs @@ -1,3 +1,3 @@ module Module -let y (f: 't & #I & #IDisposable) = () +let y (f: 't & #I & #IDisposable & #seq & #I2) = () diff --git a/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs.bsl b/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs.bsl index 83ad0deabeb..039915cb522 100644 --- a/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs.bsl +++ b/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs.bsl @@ -24,18 +24,33 @@ ImplFile Intersection (Some (SynTypar (t, None, false)), [HashConstraint + (LongIdent (SynLongIdent ([I], [], [None])), + (3,15--3,17)); + HashConstraint (LongIdent (SynLongIdent ([IDisposable], [], [None])), (3,20--3,32)); HashConstraint - (LongIdent (SynLongIdent ([I], [], [None])), - (3,15--3,17))], (3,10--3,32)), (3,7--3,32)), - (3,6--3,33))], None, (3,4--3,33)), None, - Const (Unit, (3,36--3,38)), (3,4--3,33), NoneAtLet, - { LeadingKeyword = Let (3,0--3,3) - InlineKeyword = None - EqualsRange = Some (3,34--3,35) })], (3,0--3,38))], + (App + (LongIdent + (SynLongIdent ([seq], [], [None])), + Some (3,39--3,40), + [LongIdent + (SynLongIdent ([int], [], [None]))], + [], Some (3,43--3,44), false, + (3,36--3,44)), (3,35--3,44)); + HashConstraint + (LongIdent (SynLongIdent ([I2], [], [None])), + (3,47--3,50))], (3,10--3,50), + { AmpersandRanges = + [(3,13--3,14); (3,18--3,19); (3,33--3,34); + (3,45--3,46)] }), (3,7--3,50)), (3,6--3,51))], + None, (3,4--3,51)), None, Const (Unit, (3,54--3,56)), + (3,4--3,51), NoneAtLet, { LeadingKeyword = Let (3,0--3,3) + InlineKeyword = None + EqualsRange = Some (3,52--3,53) })], + (3,0--3,56))], PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, - (1,0--3,38), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + (1,0--3,56), { LeadingKeyword = Module (1,0--1,6) })], (true, true), { ConditionalDirectives = [] CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs b/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs index 8b050ec48d3..f710889da03 100644 --- a/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs +++ b/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs @@ -1,4 +1,4 @@ module Module type I = - abstract h: #IDisposable & #seq -> unit \ No newline at end of file + abstract h: #IDisposable & #seq & #I -> unit \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs.bsl b/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs.bsl index 5fbcc82c4d5..ada151dacf1 100644 --- a/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs.bsl +++ b/tests/service/data/SyntaxTree/SynType/Constraint intersection 03.fs.bsl @@ -32,15 +32,19 @@ ImplFile [LongIdent (SynLongIdent ([int], [], [None]))], [], Some (4,39--4,40), false, - (4,32--4,40)), (4,31--4,40))], - (4,16--4,40)), + (4,32--4,40)), (4,31--4,40)); + HashConstraint + (LongIdent (SynLongIdent ([I], [], [None])), + (4,43--4,45))], (4,16--4,45), + { AmpersandRanges = + [(4,29--4,30); (4,41--4,42)] }), LongIdent (SynLongIdent ([unit], [], [None])), - (4,16--4,48), { ArrowRange = (4,41--4,43) }), + (4,16--4,53), { ArrowRange = (4,46--4,48) }), SynValInfo ([[SynArgInfo ([], false, None)]], SynArgInfo ([], false, None)), false, false, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, (4,4--4,48), + None, None, (4,4--4,53), { LeadingKeyword = Abstract (4,4--4,12) InlineKeyword = None WithKeyword = None @@ -50,12 +54,12 @@ ImplFile IsOverrideOrExplicitImpl = false IsFinal = false GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, (4,4--4,48), - { GetSetKeywords = None })], (4,4--4,48)), [], None, - (3,5--4,48), { LeadingKeyword = Type (3,0--3,4) + MemberKind = Member }, (4,4--4,53), + { GetSetKeywords = None })], (4,4--4,53)), [], None, + (3,5--4,53), { LeadingKeyword = Type (3,0--3,4) EqualsRange = Some (3,7--3,8) - WithKeyword = None })], (3,0--4,48))], + WithKeyword = None })], (3,0--4,53))], PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, - (1,0--4,48), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + (1,0--4,53), { LeadingKeyword = Module (1,0--1,6) })], (true, true), { ConditionalDirectives = [] CodeComments = [] }, set [])) From e9269321c2767fb63217162fffbcf562c4be21e4 Mon Sep 17 00:00:00 2001 From: kerams Date: Fri, 16 Jun 2023 22:11:41 +0200 Subject: [PATCH 05/12] Fix test --- .../Language/ConstraintIntersectionTests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs index 6ec5655f0c5..15689518f2e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs @@ -58,5 +58,5 @@ let y (f: #seq & System.IDisposable) = () |> typecheck |> shouldFail |> withDiagnostics [ - Error 3568, Line 2, Col 23, Line 2, Col 41, "Constraint intersection syntax may only be used with flexible types." + Error 3568, Line 2, Col 23, Line 2, Col 41, "Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." ] \ No newline at end of file From 3da5249740fad22fb036cc02e901aaacada64b32 Mon Sep 17 00:00:00 2001 From: kerams Date: Sat, 17 Jun 2023 12:42:44 +0200 Subject: [PATCH 06/12] Support constraint intersection in SynTyparDecl, add signature roundtrip test --- src/Compiler/Checking/CheckDeclarations.fs | 4 +- src/Compiler/Checking/CheckExpressions.fs | 10 +- .../GraphChecking/FileContentMapping.fs | 3 +- src/Compiler/FSComp.txt | 2 +- src/Compiler/Service/ServiceParsedInputOps.fs | 7 +- src/Compiler/Service/ServiceStructure.fs | 2 +- src/Compiler/SyntaxTree/SyntaxTree.fs | 21 +++- src/Compiler/SyntaxTree/SyntaxTree.fsi | 2 +- src/Compiler/SyntaxTree/SyntaxTrivia.fs | 8 ++ src/Compiler/SyntaxTree/SyntaxTrivia.fsi | 10 ++ src/Compiler/pars.fsy | 27 +++-- src/Compiler/xlf/FSComp.txt.cs.xlf | 10 +- src/Compiler/xlf/FSComp.txt.de.xlf | 10 +- src/Compiler/xlf/FSComp.txt.es.xlf | 10 +- src/Compiler/xlf/FSComp.txt.fr.xlf | 10 +- src/Compiler/xlf/FSComp.txt.it.xlf | 10 +- src/Compiler/xlf/FSComp.txt.ja.xlf | 10 +- src/Compiler/xlf/FSComp.txt.ko.xlf | 10 +- src/Compiler/xlf/FSComp.txt.pl.xlf | 10 +- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 10 +- src/Compiler/xlf/FSComp.txt.ru.xlf | 10 +- src/Compiler/xlf/FSComp.txt.tr.xlf | 10 +- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 10 +- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 10 +- .../Language/ConstraintIntersectionTests.fs | 33 +++++- .../intersection_constraints.fsx | 16 +++ ...ervice.SurfaceArea.netstandard20.debug.bsl | 16 ++- ...vice.SurfaceArea.netstandard20.release.bsl | 16 ++- ...p.Core.SurfaceArea.netstandard21.debug.bsl | 2 +- .../data/SyntaxTree/Member/Member 08.fs.bsl | 10 +- ...eRangeShouldStartAtNamespaceKeyword.fs.bsl | 10 +- ...ShouldEndAtTheLastSynModuleSigDecl.fsi.bsl | 50 ++++++--- .../Constraint intersection 01.fs | 4 + .../Constraint intersection 01.fs.bsl | 102 ++++++++++++++++++ ...SingleSynTypeInsideSynExprTraitCall.fs.bsl | 9 +- ...eConstraintWhereTyparSupportsMember.fs.bsl | 8 +- ...tesShouldBeIncludedInRecursiveTypes.fs.bsl | 20 ++-- 37 files changed, 390 insertions(+), 132 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/intersection_constraints.fsx create mode 100644 tests/service/data/SyntaxTree/SynTyparDecl/Constraint intersection 01.fs create mode 100644 tests/service/data/SyntaxTree/SynTyparDecl/Constraint intersection 01.fs.bsl diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index d4c15029ff0..8307bc37191 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -2536,7 +2536,7 @@ module EstablishTypeDefinitionCores = suppressErrorReporting (fun () -> synTypars|> List.forall (fun synTypar -> try - let (SynTyparDecl(Attributes synAttrs, _)) = synTypar + let (SynTyparDecl (attributes = Attributes synAttrs)) = synTypar let attrs = TcAttributes cenv env AttributeTargets.GenericParameter synAttrs HasFSharpAttribute cenv.g cenv.g.attrib_MeasureAttribute attrs with _ -> false)) @@ -3954,7 +3954,7 @@ module TcDeclarations = if tcref.TyparsNoRange.Length = synTypars.Length then (tcref.TyparsNoRange, synTypars) ||> List.zip - |> List.iter (fun (typar, SynTyparDecl.SynTyparDecl(_, SynTypar(ident = untypedIdent))) -> + |> List.iter (fun (typar, SynTyparDecl.SynTyparDecl (typar = SynTypar (ident = untypedIdent))) -> typar.SetIdent(untypedIdent) ) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 799f38d7085..1a615551060 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -4300,8 +4300,8 @@ and TcTypar (cenv: cenv) env newOk tpenv tp : Typar * UnscopedTyparEnv = and TcTyparDecl (cenv: cenv) env synTyparDecl = let g = cenv.g - let (SynTyparDecl(Attributes synAttrs, synTypar)) = synTyparDecl - let (SynTypar(id, _, _)) = synTypar + let (SynTyparDecl (attributes = Attributes synAttrs; typar = synTypar)) = synTyparDecl + let (SynTypar (ident = id)) = synTypar let attrs = TcAttributes cenv env AttributeTargets.GenericParameter synAttrs let hasMeasureAttr = HasFSharpAttribute g g.attrib_MeasureAttribute attrs @@ -4568,8 +4568,6 @@ and TcTypeHashConstraint (cenv: cenv) env newOk checkConstraints occ tpenv synTy // (x: 't & #I1 & #I2) // (x: #I1 & #I2) and TcIntersectionConstraint (cenv: cenv) env newOk checkConstraints occ tpenv synTypar synTys m = - checkLanguageFeatureAndRecover cenv.g.langVersion LanguageFeature.ConstraintIntersectionOnFlexibleTypes m - let tp, tpenv = match synTypar with | Some synTypar -> TcTypeOrMeasureParameter (Some TyparKind.Type) cenv env newOk tpenv synTypar @@ -4585,9 +4583,7 @@ and TcIntersectionConstraint (cenv: cenv) env newOk checkConstraints occ tpenv s let ty, tpenv = TcTypeAndRecover cenv newOk checkConstraints occ WarnOnIWSAM.No env tpenv ty AddCxTypeMustSubsumeType ContextInfo.NoContext env.DisplayEnv cenv.css m NoTrace ty typarTy tpenv - | _ -> - errorR(Error(FSComp.SR.tcConstraintIntersectionSyntaxUsedWithNonFlexibleType(), ty.Range)) - tpenv + | _ -> tpenv ) tpenv tp.AsType, tpenv diff --git a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs index 8f3da5a4a49..06a73ec6433 100644 --- a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs +++ b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs @@ -280,7 +280,8 @@ let visitSynTyparDecls (td: SynTyparDecls) : FileContentEntry list = | SynTyparDecls.PrefixList (decls = decls) -> List.collect visitSynTyparDecl decls | SynTyparDecls.SinglePrefix (decl = decl) -> visitSynTyparDecl decl -let visitSynTyparDecl (SynTyparDecl (attributes = attributes)) = visitSynAttributes attributes +let visitSynTyparDecl (SynTyparDecl (attributes = attributes; intersectionConstraints = constraints)) = + visitSynAttributes attributes @ List.collect visitSynType constraints let visitSynTypeConstraint (tc: SynTypeConstraint) : FileContentEntry list = [ diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 3bbfe2c00fc..56443540e5c 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1699,4 +1699,4 @@ featureEscapeBracesInFormattableString,"Escapes curly braces before calling Form featureInformationalObjInferenceDiagnostic,"Diagnostic 3559 (warn when obj inferred) at informational level, off by default" 3566,tcMultipleRecdTypeChoice,"Multiple type matches were found:\n%s\nThe type '%s' was used. Due to the overlapping field names\n%s\nconsider using type annotations or change the order of open statements." 3567,parsMissingMemberBody,"Expecting member body" -3568,tcConstraintIntersectionSyntaxUsedWithNonFlexibleType,"Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." \ No newline at end of file +3568,parsConstraintIntersectionSyntaxUsedWithNonFlexibleType,"Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." \ No newline at end of file diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index bbd4ee275be..981a3a7f881 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -599,10 +599,12 @@ module ParsedInput = ifPosInRange ident.idRange (fun _ -> Some EntityKind.Type) and walkTyparDecl typarDecl = - let (SynTyparDecl (Attributes attrs, typar)) = typarDecl + let (SynTyparDecl (Attributes attrs, typar, intersectionContraints, _)) = typarDecl List.tryPick walkAttribute attrs |> Option.orElseWith (fun () -> walkTypar typar) + |> Option.orElseWith (fun () -> + intersectionContraints |> List.tryPick walkType) and walkTypeConstraint cx = match cx with @@ -1610,9 +1612,10 @@ module ParsedInput = addLongIdentWithDots attr.TypeName walkExpr attr.ArgExpr - and walkTyparDecl (SynTyparDecl.SynTyparDecl (Attributes attrs, typar)) = + and walkTyparDecl (SynTyparDecl.SynTyparDecl (Attributes attrs, typar, intersectionConstraints, _)) = List.iter walkAttribute attrs walkTypar typar + List.iter walkType intersectionConstraints and walkTypeConstraint cx = match cx with diff --git a/src/Compiler/Service/ServiceStructure.fs b/src/Compiler/Service/ServiceStructure.fs index 93625581f3d..68cea33fe8d 100644 --- a/src/Compiler/Service/ServiceStructure.fs +++ b/src/Compiler/Service/ServiceStructure.fs @@ -62,7 +62,7 @@ module Structure = | [] -> other | ls -> ls - |> List.map (fun (SynTyparDecl (_, typarg)) -> typarg.Range) + |> List.map (fun (SynTyparDecl (typar = typarg)) -> typarg.Range) |> List.reduce unionRanges /// Collapse indicates the way a range/snapshot should be collapsed. `Same` is for a scope inside diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index f6edb890a86..905b651f9ed 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -309,7 +309,7 @@ type SynBindingKind = | Do [] -type SynTyparDecl = SynTyparDecl of attributes: SynAttributes * SynTypar +type SynTyparDecl = SynTyparDecl of attributes: SynAttributes * typar: SynTypar * intersectionConstraints: SynType list * trivia: SynTyparDeclTrivia [] type SynTypeConstraint = @@ -367,13 +367,28 @@ type SynTyparDecls = member x.Constraints = match x with - | PostfixList (constraints = constraints) -> constraints + | PostfixList (decls = decls; constraints = constraints) -> + // Synthesize SynTypeConstraints implied with any intersection constraints in SynTyparDecl + // The parser makes sure we're only dealing with hash constraints here + let intersectionConstraints = + decls + |> List.collect (fun (SynTyparDecl (typar = tp; intersectionConstraints = tys)) -> + tys + |> List.map (fun ty -> + let ty = + match ty with + | SynType.HashConstraint (ty, _) -> ty + | _ -> ty + + SynTypeConstraint.WhereTyparSubtypeOfType (tp, ty, ty.Range))) + + List.append intersectionConstraints constraints | _ -> [] member x.Range = match x with | PostfixList (range = range) - | PrefixList (range = range) -> range + | PrefixList (range = range) | SinglePrefix (range = range) -> range [] diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 1063655fbab..716b67fa39b 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -374,7 +374,7 @@ type SynBindingKind = /// Represents the explicit declaration of a type parameter [] -type SynTyparDecl = SynTyparDecl of attributes: SynAttributes * SynTypar +type SynTyparDecl = SynTyparDecl of attributes: SynAttributes * typar: SynTypar * intersectionConstraints: SynType list * trivia: SynTyparDeclTrivia /// The unchecked abstract syntax tree of F# type constraints [] diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fs b/src/Compiler/SyntaxTree/SyntaxTrivia.fs index abe3fa898ba..77f29206039 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fs +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fs @@ -384,3 +384,11 @@ type SynMemberSigMemberTrivia = [] type SynTypeIntersectionTrivia = { AmpersandRanges: range list } + +[] +type SynTyparDeclTrivia = + { + AmpersandRanges: range list + } + + static member Zero: SynTyparDeclTrivia = { AmpersandRanges = [] } \ No newline at end of file diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi index d19f89965ae..d6ea86d4b02 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi @@ -509,3 +509,13 @@ type SynTypeIntersectionTrivia = /// The syntax ranges of the `&` tokens AmpersandRanges: range list } + +/// Represents additional information for SynTyparDecl +[] +type SynTyparDeclTrivia = + { + /// The syntax ranges of the `&` tokens + AmpersandRanges: range list + } + + static member Zero: SynTyparDeclTrivia diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index acfa5a30cb2..0e74bee3391 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -2313,7 +2313,7 @@ tyconNameAndTyparDecls: prefixTyparDecls: | typar - { SynTyparDecls.SinglePrefix(SynTyparDecl([], $1), rhs parseState 1) } + { SynTyparDecls.SinglePrefix(SynTyparDecl([], $1, [], SynTyparDeclTrivia.Zero), rhs parseState 1) } | LPAREN typarDeclList rparen { SynTyparDecls.PrefixList(List.rev $2, rhs2 parseState 1 3) } @@ -2322,9 +2322,14 @@ typarDeclList: | typarDeclList COMMA typarDecl { $3 :: $1 } | typarDecl { [$1] } -typarDecl : +typarDecl: | opt_attributes typar - { SynTyparDecl($1, $2) } + { SynTyparDecl($1, $2, [], SynTyparDeclTrivia.Zero) } + + | opt_attributes typar AMP intersectionConstraints + { parseState.LexBuffer.CheckLanguageFeatureAndRecover LanguageFeature.ConstraintIntersectionOnFlexibleTypes (rhs2 parseState 3 4) + let constraints, mAmpersands = $4 + SynTyparDecl($1, $2, List.rev constraints, { AmpersandRanges = rhs parseState 3 :: List.rev mAmpersands }) } /* Any tokens in this grammar must be added to the lex filter rule 'peekAdjacentTypars' */ /* See the F# specification "Lexical analysis of type applications and type parameter definitions" */ @@ -2383,10 +2388,19 @@ typeConstraints: intersectionConstraints: | intersectionConstraints AMP atomType %prec prec_no_more_attr_bindings // todo precedence { let constraints, mAmpersands = $1 + + match $3 with + | SynType.HashConstraint _ -> () + | ty -> errorR(Error(FSComp.SR.parsConstraintIntersectionSyntaxUsedWithNonFlexibleType(), ty.Range)) + ($3 :: constraints), (rhs parseState 2 :: mAmpersands) } | atomType - { [ $1 ], [] } + { match $1 with + | SynType.HashConstraint _ -> () + | ty -> errorR(Error(FSComp.SR.parsConstraintIntersectionSyntaxUsedWithNonFlexibleType(), ty.Range)) + + [ $1 ], [] } /* Any tokens in this grammar must be added to the lex filter rule 'peekAdjacentTypars' */ /* See the F# specification "Lexical analysis of type applications and type parameter definitions" */ @@ -5674,8 +5688,6 @@ tupleOrQuotTypeElements: | appType %prec prec_tuptyptail_prefix { [ SynTupleTypeSegment.Type $1 ] } -/* Any tokens in this grammar must be added to the lex filter rule 'peekAdjacentTypars' */ -/* See the F# specification "Lexical analysis of type applications and type parameter definitions" */ intersectionType: | typar AMP intersectionConstraints %prec prec_no_more_attr_bindings // todo precedence { let constraints, mAmpersands = $3 @@ -5724,7 +5736,8 @@ appType: { $1 } | intersectionType - { $1 } + { parseState.LexBuffer.CheckLanguageFeatureAndRecover LanguageFeature.ConstraintIntersectionOnFlexibleTypes (lhs parseState) + $1 } | typar COLON_GREATER typ { let tp, typ = $1, $3 diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 654052533db..9f0bb18430f 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -767,6 +767,11 @@ Funkce správy balíčků vyžaduje jazykovou verzi 5.0 nebo vyšší. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Neplatný interpolovaný řetězec. Vyplnění výrazu interpolovaného řetězce je prázdné, očekával se výraz. @@ -987,11 +992,6 @@ Atributy nejde použít pro rozšíření typů. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Tento výraz záznamu kopírování a aktualizace mění všechna pole typu záznamu '{0}'. Zvažte použití syntaxe konstrukce záznamu. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index b35a4fc8c66..fcda90d69df 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -767,6 +767,11 @@ Für das „Paketverwaltungsfeature“ ist Sprachversion 5.0 oder höher erforderlich + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Ungültige interpolierte Zeichenfolge. Die Ausdrucksfüllung der interpolierten Zeichenfolge ist leer. Es wurde ein Ausdruck erwartet. @@ -987,11 +992,6 @@ Attribute können nicht auf Typerweiterungen angewendet werden. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Dieser Ausdruck zum Kopieren und Aktualisieren von Datensätzen ändert alle Felder des Datensatztyps "{0}". Erwägen Sie stattdessen die Verwendung der Datensatzerstellungssyntax. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 5ad81ff6127..7c4013df51d 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -767,6 +767,11 @@ La característica de "administración de paquetes" requiere la versión de lenguaje 5.0 o superior + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Cadena interpolada no válida. Este relleno de expresión de cadena interpolada está vacío; se esperaba una expresión. @@ -987,11 +992,6 @@ Los atributos no se pueden aplicar a las extensiones de tipo. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Esta expresión de copia y actualización de registros cambia todos los campos de tipo de registro "{0}". Es preferible utilizar la sintaxis de construcción de registros. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 7349b75e5ed..7e553b0330f 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -767,6 +767,11 @@ La fonction « gestion des paquets » nécessite une version de langue 5.0 ou supérieure. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Chaîne interpolée non valide. Le remplissage de cette expression de chaîne interpolée est vide. Une expression est attendue. @@ -987,11 +992,6 @@ Impossible d'appliquer des attributs aux extensions de type. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Cette expression d'enregistrement de copie et de mise à jour modifie tous les champs du type d'enregistrement '{0}'. Envisagez d'utiliser la syntaxe de construction d'enregistrement à la place. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index d550eaf2149..eb4a94f9905 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -767,6 +767,11 @@ La funzionalità 'gestione pacchetti' richiede la versione del linguaggio 5.0 o superiore + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. La stringa interpolata non è valida. Il riempimento espressione di questa stringa interpolata è vuoto, mentre era prevista un'espressione. @@ -987,11 +992,6 @@ Gli attributi non possono essere applicati a estensioni di tipo. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Questa espressione di record di copia e aggiornamento modifica tutti i campi del tipo di record '{0}'. Provare a usare la sintassi di costruzione dei record. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 11b114a3fed..4ab42681602 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -767,6 +767,11 @@ 'package management' (パッケージ管理) 機能には、言語バージョン 5.0 以降が必要です + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. 補間された文字列が無効です。この補間された文字列式の塗りつぶしが空です。式が必要です。 @@ -987,11 +992,6 @@ 属性を型拡張に適用することはできません。 - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. この copy-and-update レコード式は、レコードの種類が '{0}' であるすべてのフィールドを変更します。代わりにレコード構築構文を使用することを検討してください。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index ec43ee9d83e..54b2b6724b9 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -767,6 +767,11 @@ '패키지 관리' 기능을 사용하려면 언어 버전 5.0 이상이 필요합니다. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. 보간된 문자열이 잘못되었습니다. 이 보간된 문자열 식 채우기가 비어 있는데, 식이 필요합니다. @@ -987,11 +992,6 @@ 형식 확장에 특성을 적용할 수 없습니다. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. 이 레코드 복사 및 업데이트 식은 '{0}' 레코드 형식의 모든 필드를 변경합니다. 레코드 생성 구문을 대신 사용하는 것이 좋습니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 8d7e38b73a9..e84c7fba4ce 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -767,6 +767,11 @@ Funkcja „Zarządzanie pakietami” wymaga języka w wersji 5.0 lub nowszej + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Nieprawidłowy ciąg interpolowany. Wyrażenie ciągu interpolowanego nie jest wypełnione, a jest oczekiwane. @@ -987,11 +992,6 @@ Atrybutów nie można stosować do rozszerzeń typu. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. To wyrażenie rekordu kopiowania i aktualizacji zmienia wszystkie pola typu rekordu „{0}”. Zamiast tego rozważ użycie składni konstrukcji rekordu. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index b1c250edc59..2c19b20e73f 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -767,6 +767,11 @@ O recurso 'gerenciamento de pacotes' requer a versão 5.0 ou superior do idioma + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Cadeia de caracteres interpolada inválida. O preenchimento dessa expressão de cadeia de caracteres interpolada está vazio. Era esperada uma expressão. @@ -987,11 +992,6 @@ Os atributos não podem ser aplicados às extensões de tipo. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Essa expressão de registro copiar e atualizar altera todos os campos do tipo de registro '{0}'. Considere usar a sintaxe de construção de registro em vez disso. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 3c3fc7cea8b..d8433631db5 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -767,6 +767,11 @@ Для функции управления пакетами требуется версия языка 5.0 или более поздняя + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Недопустимая интерполированная строка. Выражение этой интерполированной строки является пустым. Ожидается выражение. @@ -987,11 +992,6 @@ Атрибуты не могут быть применены к расширениям типа. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Это выражение записи копирования и обновления изменяет все поля типа записи "{0}". Вместо этого можно использовать синтаксис конструкции записи. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 943c0601cd4..0e543cf5b9f 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -767,6 +767,11 @@ ‘Paket yönetimi’ özelliği, dil sürümü 5.0 veya üstünü gerektirir + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Düz metin arasına kod eklenmiş dize geçersiz. Bu düz metin arasına kod eklenmiş dize ifade dolgusu boş. İfade bekleniyordu. @@ -987,11 +992,6 @@ Öznitelikler tür uzantılarına uygulanamaz. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. Bu kopyalama ve güncelleştirme kayıt ifadesi, '{0}' kayıt türündeki tüm alanları değiştirir. Bunun yerine kayıt oluşturma söz dizimini kullanmayı deneyin. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 56e1047162c..095dcecae34 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -767,6 +767,11 @@ “包管理”功能需要语言版本 5.0 或更高版本 + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. 内插字符串无效。此内插字符串表达式填充为空,应为表达式。 @@ -987,11 +992,6 @@ 属性不可应用于类型扩展。 - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. 此复制和更新记录表达式更改记录类型“{0}”的所有字段。请考虑改用记录构造语法。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 9148ad7c70e..67f260e97bb 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -767,6 +767,11 @@ 「套件管理」功能需要語言版本 5.0 或更新版本 + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. 插補字串無效。此插補字串運算式填滿為空白,必須有運算式。 @@ -987,11 +992,6 @@ 屬性無法套用到類型延伸模組。 - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. 此複製和更新記錄運算式將變更記錄類型為 '{0}' 的所有欄位。請考慮改用記錄建構語法。 diff --git a/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs index 15689518f2e..2ac9b527e4b 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs @@ -5,7 +5,7 @@ open FSharp.Test.Compiler open StructuredResultsAsserts [] -let ``Constraint intersection works in lang preview``() = +let ``Constraint intersection (appType) works in lang preview``() = FSharp """ open System open System.Threading.Tasks @@ -35,12 +35,14 @@ let x (f: 't & #I) = f.h (new E ()) ResizeArray<'t> () -let y (f: 't & #I & #IDisposable) = +let y (f: 't & #I & #IDisposable, name: string) = + printfn "%s" name f.g () f.Dispose () ResizeArray<'t> () -let z (f: #I & #IDisposable & #Task & #seq) = +let z (f: #I & #IDisposable & #Task & #seq, name: string) = + printfn "%s" name f.g () f.Result |> ignore f.Dispose () @@ -49,14 +51,37 @@ let z (f: #I & #IDisposable & #Task & #seq) = |> typecheck |> shouldSucceed +[] +let ``Constraint intersection (typarDecl) works in lang preview``() = + FSharp """ +open System + +type C<'t & #seq & #IDisposable, 'y & #seq<'t>> = + member _.G (x: 't, y: 'y) = + for x in x do + printfn "%d" x + + x.Dispose () + + for xs in y do + for x in xs do + printfn "%d" x + """ + |> withLangVersionPreview + |> typecheck + |> shouldSucceed + [] let ``Constraint intersection does not work with non-flexible types``() = FSharp """ +type C<'t & #seq & System.IDisposable, 'y & #seq<'t>> = class end + let y (f: #seq & System.IDisposable) = () """ |> withLangVersionPreview |> typecheck |> shouldFail |> withDiagnostics [ - Error 3568, Line 2, Col 23, Line 2, Col 41, "Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." + Error 3568, Line 2, Col 25, Line 2, Col 43, "Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." + Error 3568, Line 4, Col 23, Line 4, Col 41, "Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/intersection_constraints.fsx b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/intersection_constraints.fsx new file mode 100644 index 00000000000..d8555dfbed8 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Signatures/TestCasesForGenerationRoundTrip/intersection_constraints.fsx @@ -0,0 +1,16 @@ +module Foo + +open System +open System.Threading.Tasks + +type I = + abstract g: unit -> unit + abstract h: #IDisposable & #seq -> unit + +let x (f: 't & #I) = () + +let y (f: 't & #I & #IDisposable, name: string) = () + +let z (f: #I & #IDisposable & #Task & #seq, name: string) = () + +type C<'t & #seq & #IDisposable, 'y & #seq<'t>> = class end diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index b39123fc018..7ca08ec20f3 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -8346,13 +8346,17 @@ FSharp.Compiler.Syntax.SynTypar: FSharp.Compiler.Text.Range get_Range() FSharp.Compiler.Syntax.SynTypar: Int32 Tag FSharp.Compiler.Syntax.SynTypar: Int32 get_Tag() FSharp.Compiler.Syntax.SynTypar: System.String ToString() -FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTypar Item2 -FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTypar get_Item2() -FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTyparDecl NewSynTyparDecl(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Syntax.SynTypar) +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTypar get_typar() +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTypar typar +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTyparDecl NewSynTyparDecl(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Syntax.SynTypar, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia) +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia get_trivia() +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia trivia FSharp.Compiler.Syntax.SynTyparDecl: Int32 Tag FSharp.Compiler.Syntax.SynTyparDecl: Int32 get_Tag() FSharp.Compiler.Syntax.SynTyparDecl: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList] attributes FSharp.Compiler.Syntax.SynTyparDecl: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList] get_attributes() +FSharp.Compiler.Syntax.SynTyparDecl: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] get_intersectionConstraints() +FSharp.Compiler.Syntax.SynTyparDecl: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] intersectionConstraints FSharp.Compiler.Syntax.SynTyparDecl: System.String ToString() FSharp.Compiler.Syntax.SynTyparDecls+PostfixList: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynTyparDecls+PostfixList: FSharp.Compiler.Text.Range range @@ -9798,6 +9802,12 @@ FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia: FSharp.Compiler.Text.Range BarRange FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia: FSharp.Compiler.Text.Range get_BarRange() FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia: Void .ctor(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia Zero +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia get_Zero() +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range] AmpersandRanges +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range] get_AmpersandRanges() +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: Void .ctor(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynTypeDefnLeadingKeyword+And: FSharp.Compiler.Text.Range Item FSharp.Compiler.SyntaxTrivia.SynTypeDefnLeadingKeyword+And: FSharp.Compiler.Text.Range get_Item() FSharp.Compiler.SyntaxTrivia.SynTypeDefnLeadingKeyword+StaticType: FSharp.Compiler.Text.Range get_staticRange() diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index b7a8c358dad..3c642f1c4d3 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -8346,13 +8346,17 @@ FSharp.Compiler.Syntax.SynTypar: FSharp.Compiler.Text.Range get_Range() FSharp.Compiler.Syntax.SynTypar: Int32 Tag FSharp.Compiler.Syntax.SynTypar: Int32 get_Tag() FSharp.Compiler.Syntax.SynTypar: System.String ToString() -FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTypar Item2 -FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTypar get_Item2() -FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTyparDecl NewSynTyparDecl(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Syntax.SynTypar) +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTypar get_typar() +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTypar typar +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTyparDecl NewSynTyparDecl(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Syntax.SynTypar, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia) +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia get_trivia() +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia trivia FSharp.Compiler.Syntax.SynTyparDecl: Int32 Tag FSharp.Compiler.Syntax.SynTyparDecl: Int32 get_Tag() FSharp.Compiler.Syntax.SynTyparDecl: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList] attributes FSharp.Compiler.Syntax.SynTyparDecl: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList] get_attributes() +FSharp.Compiler.Syntax.SynTyparDecl: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] get_intersectionConstraints() +FSharp.Compiler.Syntax.SynTyparDecl: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] intersectionConstraints FSharp.Compiler.Syntax.SynTyparDecl: System.String ToString() FSharp.Compiler.Syntax.SynTyparDecls+PostfixList: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynTyparDecls+PostfixList: FSharp.Compiler.Text.Range range @@ -9798,6 +9802,12 @@ FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia: FSharp.Compiler.Text.Range BarRange FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia: FSharp.Compiler.Text.Range get_BarRange() FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia: Void .ctor(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia Zero +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia get_Zero() +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range] AmpersandRanges +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range] get_AmpersandRanges() +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: Void .ctor(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynTypeDefnLeadingKeyword+And: FSharp.Compiler.Text.Range Item FSharp.Compiler.SyntaxTrivia.SynTypeDefnLeadingKeyword+And: FSharp.Compiler.Text.Range get_Item() FSharp.Compiler.SyntaxTrivia.SynTypeDefnLeadingKeyword+StaticType: FSharp.Compiler.Text.Range get_staticRange() diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.debug.bsl b/tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.debug.bsl index 29f826a24ba..1b2f3a0e052 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.debug.bsl +++ b/tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.debug.bsl @@ -1002,7 +1002,7 @@ Microsoft.FSharp.Core.ExtraTopLevelOperators: T PrintFormatToTextWriter[T](Syste Microsoft.FSharp.Core.ExtraTopLevelOperators: T PrintFormat[T](Microsoft.FSharp.Core.PrintfFormat`4[T,System.IO.TextWriter,Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Core.Unit]) Microsoft.FSharp.Core.ExtraTopLevelOperators: T SpliceExpression[T](Microsoft.FSharp.Quotations.FSharpExpr`1[T]) Microsoft.FSharp.Core.ExtraTopLevelOperators: T SpliceUntypedExpression[T](Microsoft.FSharp.Quotations.FSharpExpr) -Microsoft.FSharp.Core.ExtraTopLevelOperators: T[,] CreateArray2D[?,T](System.Collections.Generic.IEnumerable`1[?]) +Microsoft.FSharp.Core.ExtraTopLevelOperators: T[,] CreateArray2D[a,T](System.Collections.Generic.IEnumerable`1[a]) Microsoft.FSharp.Core.FSharpChoice`2+Choice1Of2[T1,T2]: T1 Item Microsoft.FSharp.Core.FSharpChoice`2+Choice1Of2[T1,T2]: T1 get_Item() Microsoft.FSharp.Core.FSharpChoice`2+Choice2Of2[T1,T2]: T2 Item diff --git a/tests/service/data/SyntaxTree/Member/Member 08.fs.bsl b/tests/service/data/SyntaxTree/Member/Member 08.fs.bsl index 92a358d24d8..d7a7eda73ea 100644 --- a/tests/service/data/SyntaxTree/Member/Member 08.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Member 08.fs.bsl @@ -9,9 +9,13 @@ ImplFile ([], Some (PostfixList - ([SynTyparDecl ([], SynTypar (T, None, false)); - SynTyparDecl ([], SynTypar (Measure, None, false))], - [], (3,17--3,30))), [], [INumericNorm], + ([SynTyparDecl + ([], SynTypar (T, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (Measure, None, false), [], + { AmpersandRanges = [] })], [], (3,17--3,30))), + [], [INumericNorm], PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), true, None, (3,5--3,17)), ObjectModel diff --git a/tests/service/data/SyntaxTree/ModuleOrNamespace/DeclaredNamespaceRangeShouldStartAtNamespaceKeyword.fs.bsl b/tests/service/data/SyntaxTree/ModuleOrNamespace/DeclaredNamespaceRangeShouldStartAtNamespaceKeyword.fs.bsl index ee8d2ef0130..e45507b4a0d 100644 --- a/tests/service/data/SyntaxTree/ModuleOrNamespace/DeclaredNamespaceRangeShouldStartAtNamespaceKeyword.fs.bsl +++ b/tests/service/data/SyntaxTree/ModuleOrNamespace/DeclaredNamespaceRangeShouldStartAtNamespaceKeyword.fs.bsl @@ -12,9 +12,13 @@ ImplFile ([], Some (PostfixList - ([SynTyparDecl ([], SynTypar (a, None, false)); - SynTyparDecl ([], SynTypar (b, None, false))], [], - (5,8--5,16))), [], [Teq], + ([SynTyparDecl + ([], SynTypar (a, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (b, None, false), [], + { AmpersandRanges = [] })], [], (5,8--5,16))), [], + [Teq], PreXmlDoc ((5,0), FSharp.Compiler.Xml.XmlDocCollector), true, None, (5,5--5,8)), Simple (None (5,5--5,8), (5,5--5,8)), [], None, (4,0--5,8), diff --git a/tests/service/data/SyntaxTree/NestedModule/RangeOfNestedModuleInSignatureFileShouldEndAtTheLastSynModuleSigDecl.fsi.bsl b/tests/service/data/SyntaxTree/NestedModule/RangeOfNestedModuleInSignatureFileShouldEndAtTheLastSynModuleSigDecl.fsi.bsl index 045d27fa6d3..c949211307e 100644 --- a/tests/service/data/SyntaxTree/NestedModule/RangeOfNestedModuleInSignatureFileShouldEndAtTheLastSynModuleSigDecl.fsi.bsl +++ b/tests/service/data/SyntaxTree/NestedModule/RangeOfNestedModuleInSignatureFileShouldEndAtTheLastSynModuleSigDecl.fsi.bsl @@ -41,11 +41,19 @@ SigFile ([], Some (PostfixList - ([SynTyparDecl ([], SynTypar (T1, None, false)); - SynTyparDecl ([], SynTypar (T2, None, false)); - SynTyparDecl ([], SynTypar (T3, None, false)); - SynTyparDecl ([], SynTypar (T4, None, false))], - [], (13,14--13,31))), [], [Tuple], + ([SynTyparDecl + ([], SynTypar (T1, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (T2, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (T3, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (T4, None, false), [], + { AmpersandRanges = [] })], [], + (13,14--13,31))), [], [Tuple], PreXmlDoc ((13,4), FSharp.Compiler.Xml.XmlDocCollector), true, None, (13,9--13,14)), ObjectModel @@ -255,13 +263,25 @@ SigFile Range = (28,4--28,38) }], Some (PostfixList - ([SynTyparDecl ([], SynTypar (T1, None, false)); - SynTyparDecl ([], SynTypar (T2, None, false)); - SynTyparDecl ([], SynTypar (T3, None, false)); - SynTyparDecl ([], SynTypar (T4, None, false)); - SynTyparDecl ([], SynTypar (T5, None, false)); - SynTyparDecl ([], SynTypar (T6, None, false))], - [], (29,15--29,40))), [], [Choice], + ([SynTyparDecl + ([], SynTypar (T1, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (T2, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (T3, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (T4, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (T5, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (T6, None, false), [], + { AmpersandRanges = [] })], [], + (29,15--29,40))), [], [Choice], PreXmlDoc ((27,4), FSharp.Compiler.Xml.XmlDocCollector), true, None, (29,9--29,15)), Simple @@ -374,8 +394,10 @@ SigFile ([], Some (PostfixList - ([SynTyparDecl ([], SynTypar (T, None, false))], - [], (49,16--49,20))), [], [[,]], + ([SynTyparDecl + ([], SynTypar (T, None, false), [], + { AmpersandRanges = [] })], [], + (49,16--49,20))), [], [[,]], PreXmlDoc ((49,4), FSharp.Compiler.Xml.XmlDocCollector), true, None, (49,9--49,16)), Simple (None (49,9--61,26), (49,9--61,26)), diff --git a/tests/service/data/SyntaxTree/SynTyparDecl/Constraint intersection 01.fs b/tests/service/data/SyntaxTree/SynTyparDecl/Constraint intersection 01.fs new file mode 100644 index 00000000000..e67f1501f22 --- /dev/null +++ b/tests/service/data/SyntaxTree/SynTyparDecl/Constraint intersection 01.fs @@ -0,0 +1,4 @@ +module Module + +type C<'t & #seq & #IDisposable & #I, 'y & #seq<'t>> = + member _.G (x: 't, y: 'y) = () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/SynTyparDecl/Constraint intersection 01.fs.bsl b/tests/service/data/SyntaxTree/SynTyparDecl/Constraint intersection 01.fs.bsl new file mode 100644 index 00000000000..96d2a16e16c --- /dev/null +++ b/tests/service/data/SyntaxTree/SynTyparDecl/Constraint intersection 01.fs.bsl @@ -0,0 +1,102 @@ +ImplFile + (ParsedImplFileInput + ("/root/SynTyparDecl/Constraint intersection 01.fs", false, + QualifiedNameOfFile Module, [], [], + [SynModuleOrNamespace + ([Module], false, NamedModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], + Some + (PostfixList + ([SynTyparDecl + ([], SynTypar (t, None, false), + [HashConstraint + (App + (LongIdent + (SynLongIdent ([seq], [], [None])), + Some (3,16--3,17), + [LongIdent + (SynLongIdent ([int], [], [None]))], [], + Some (3,20--3,21), false, (3,13--3,21)), + (3,12--3,21)); + HashConstraint + (LongIdent + (SynLongIdent ([IDisposable], [], [None])), + (3,24--3,36)); + HashConstraint + (LongIdent (SynLongIdent ([I], [], [None])), + (3,39--3,41))], + { AmpersandRanges = + [(3,10--3,11); (3,22--3,23); (3,37--3,38)] }); + SynTyparDecl + ([], SynTypar (y, None, false), + [HashConstraint + (App + (LongIdent + (SynLongIdent ([seq], [], [None])), + Some (3,52--3,53), + [Var + (SynTypar (t, None, false), + (3,53--3,55))], [], Some (3,55--3,56), + false, (3,49--3,56)), (3,48--3,56))], + { AmpersandRanges = [(3,46--3,47)] })], [], + (3,6--3,57))), [], [C], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + true, None, (3,5--3,6)), + ObjectModel + (Unspecified, + [Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; + [SynArgInfo ([], false, Some x); + SynArgInfo ([], false, Some y)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; G], [(4,12--4,13)], [None; None]), None, + None, + Pats + [Paren + (Tuple + (false, + [Typed + (Named + (SynIdent (x, None), false, None, + (4,16--4,17)), + Var + (SynTypar (t, None, false), + (4,19--4,21)), (4,16--4,21)); + Typed + (Named + (SynIdent (y, None), false, None, + (4,23--4,24)), + Var + (SynTypar (y, None, false), + (4,26--4,28)), (4,23--4,28))], + [(4,21--4,22)], (4,16--4,28)), + (4,15--4,29))], None, (4,11--4,29)), None, + Const (Unit, (4,32--4,34)), (4,11--4,29), + NoneAtInvisible, + { LeadingKeyword = Member (4,4--4,10) + InlineKeyword = None + EqualsRange = Some (4,30--4,31) }), (4,4--4,34))], + (4,4--4,34)), [], None, (3,5--4,34), + { LeadingKeyword = Type (3,0--3,4) + EqualsRange = Some (3,58--3,59) + WithKeyword = None })], (3,0--4,34))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--4,34), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/SynType/SingleSynTypeInsideSynExprTraitCall.fs.bsl b/tests/service/data/SyntaxTree/SynType/SingleSynTypeInsideSynExprTraitCall.fs.bsl index f5c0013ec18..9ed3e51aa43 100644 --- a/tests/service/data/SyntaxTree/SynType/SingleSynTypeInsideSynExprTraitCall.fs.bsl +++ b/tests/service/data/SyntaxTree/SynType/SingleSynTypeInsideSynExprTraitCall.fs.bsl @@ -34,11 +34,14 @@ ImplFile (Some (PostfixList ([SynTyparDecl - ([], SynTypar (a, HeadType, false)); + ([], SynTypar (a, HeadType, false), + [], { AmpersandRanges = [] }); SynTyparDecl - ([], SynTypar (b, HeadType, false)); + ([], SynTypar (b, HeadType, false), + [], { AmpersandRanges = [] }); SynTyparDecl - ([], SynTypar (c, HeadType, false))], + ([], SynTypar (c, HeadType, false), + [], { AmpersandRanges = [] })], [WhereTyparSupportsMember (Var (SynTypar (b, HeadType, false), diff --git a/tests/service/data/SyntaxTree/SynType/SynTypeOrInsideSynTypeConstraintWhereTyparSupportsMember.fs.bsl b/tests/service/data/SyntaxTree/SynType/SynTypeOrInsideSynTypeConstraintWhereTyparSupportsMember.fs.bsl index 8cf244eae01..5b687420cb8 100644 --- a/tests/service/data/SyntaxTree/SynType/SynTypeOrInsideSynTypeConstraintWhereTyparSupportsMember.fs.bsl +++ b/tests/service/data/SyntaxTree/SynType/SynTypeOrInsideSynTypeConstraintWhereTyparSupportsMember.fs.bsl @@ -20,8 +20,12 @@ ImplFile (SynValTyparDecls (Some (PostfixList - ([SynTyparDecl ([], SynTypar (T1, None, false)); - SynTyparDecl ([], SynTypar (T2, None, false))], + ([SynTyparDecl + ([], SynTypar (T1, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (T2, None, false), [], + { AmpersandRanges = [] })], [WhereTyparSupportsMember (Paren (Or diff --git a/tests/service/data/SyntaxTree/Type/RangeOfAttributesShouldBeIncludedInRecursiveTypes.fs.bsl b/tests/service/data/SyntaxTree/Type/RangeOfAttributesShouldBeIncludedInRecursiveTypes.fs.bsl index e075cf77635..8ae96be677d 100644 --- a/tests/service/data/SyntaxTree/Type/RangeOfAttributesShouldBeIncludedInRecursiveTypes.fs.bsl +++ b/tests/service/data/SyntaxTree/Type/RangeOfAttributesShouldBeIncludedInRecursiveTypes.fs.bsl @@ -22,9 +22,13 @@ ImplFile Range = (2,0--2,29) }], Some (PostfixList - ([SynTyparDecl ([], SynTypar (context, None, false)); - SynTyparDecl ([], SynTypar (a, None, false))], [], - (3,8--3,22))), [], [Foo], + ([SynTyparDecl + ([], SynTypar (context, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (a, None, false), [], + { AmpersandRanges = [] })], [], (3,8--3,22))), [], + [Foo], PreXmlDoc ((2,0), FSharp.Compiler.Xml.XmlDocCollector), true, None, (3,5--3,8)), Simple @@ -71,9 +75,13 @@ ImplFile Range = (6,4--6,37) }], Some (PostfixList - ([SynTyparDecl ([], SynTypar (context, None, false)); - SynTyparDecl ([], SynTypar (a, None, false))], [], - (6,41--6,55))), [], [Bar], + ([SynTyparDecl + ([], SynTypar (context, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (a, None, false), [], + { AmpersandRanges = [] })], [], (6,41--6,55))), + [], [Bar], PreXmlDoc ((6,4), FSharp.Compiler.Xml.XmlDocCollector), true, None, (6,38--6,41)), Simple From a589bcf9fc65132be22681b14f9b85832e4ae0c8 Mon Sep 17 00:00:00 2001 From: kerams Date: Sat, 17 Jun 2023 12:44:24 +0200 Subject: [PATCH 07/12] Obey Fantomas --- src/Compiler/Service/ServiceParsedInputOps.fs | 3 +-- src/Compiler/SyntaxTree/SyntaxTree.fs | 5 +++-- src/Compiler/SyntaxTree/SyntaxTree.fsi | 7 ++++++- src/Compiler/SyntaxTree/SyntaxTrivia.fs | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index 981a3a7f881..5d308d124f9 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -603,8 +603,7 @@ module ParsedInput = List.tryPick walkAttribute attrs |> Option.orElseWith (fun () -> walkTypar typar) - |> Option.orElseWith (fun () -> - intersectionContraints |> List.tryPick walkType) + |> Option.orElseWith (fun () -> intersectionContraints |> List.tryPick walkType) and walkTypeConstraint cx = match cx with diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index 905b651f9ed..5b377cf51d5 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -309,7 +309,8 @@ type SynBindingKind = | Do [] -type SynTyparDecl = SynTyparDecl of attributes: SynAttributes * typar: SynTypar * intersectionConstraints: SynType list * trivia: SynTyparDeclTrivia +type SynTyparDecl = + | SynTyparDecl of attributes: SynAttributes * typar: SynTypar * intersectionConstraints: SynType list * trivia: SynTyparDeclTrivia [] type SynTypeConstraint = @@ -380,7 +381,7 @@ type SynTyparDecls = | SynType.HashConstraint (ty, _) -> ty | _ -> ty - SynTypeConstraint.WhereTyparSubtypeOfType (tp, ty, ty.Range))) + SynTypeConstraint.WhereTyparSubtypeOfType(tp, ty, ty.Range))) List.append intersectionConstraints constraints | _ -> [] diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 716b67fa39b..1ac93d91bee 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -374,7 +374,12 @@ type SynBindingKind = /// Represents the explicit declaration of a type parameter [] -type SynTyparDecl = SynTyparDecl of attributes: SynAttributes * typar: SynTypar * intersectionConstraints: SynType list * trivia: SynTyparDeclTrivia +type SynTyparDecl = + | SynTyparDecl of + attributes: SynAttributes * + typar: SynTypar * + intersectionConstraints: SynType list * + trivia: SynTyparDeclTrivia /// The unchecked abstract syntax tree of F# type constraints [] diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fs b/src/Compiler/SyntaxTree/SyntaxTrivia.fs index 77f29206039..54e20a1b432 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fs +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fs @@ -391,4 +391,4 @@ type SynTyparDeclTrivia = AmpersandRanges: range list } - static member Zero: SynTyparDeclTrivia = { AmpersandRanges = [] } \ No newline at end of file + static member Zero: SynTyparDeclTrivia = { AmpersandRanges = [] } From 8efd2ba073216423375074f9e8c20ae61afa1365 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 2 Aug 2023 12:16:53 +0200 Subject: [PATCH 08/12] resources recompiled --- src/Compiler/xlf/FSComp.txt.cs.xlf | 10 ++++++++++ src/Compiler/xlf/FSComp.txt.de.xlf | 10 ++++++++++ src/Compiler/xlf/FSComp.txt.es.xlf | 10 ++++++++++ src/Compiler/xlf/FSComp.txt.fr.xlf | 10 ++++++++++ src/Compiler/xlf/FSComp.txt.it.xlf | 10 ++++++++++ src/Compiler/xlf/FSComp.txt.ja.xlf | 10 ++++++++++ src/Compiler/xlf/FSComp.txt.ko.xlf | 10 ++++++++++ src/Compiler/xlf/FSComp.txt.pl.xlf | 10 ++++++++++ src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 10 ++++++++++ src/Compiler/xlf/FSComp.txt.ru.xlf | 10 ++++++++++ src/Compiler/xlf/FSComp.txt.tr.xlf | 10 ++++++++++ src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 10 ++++++++++ src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 10 ++++++++++ 13 files changed, 130 insertions(+) diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index eafe702269c..1493f4ba579 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -232,6 +232,11 @@ Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way. + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption využití člena výchozího rozhraní @@ -812,6 +817,11 @@ Funkce správy balíčků vyžaduje jazykovou verzi 5.0 nebo vyšší. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Neplatný interpolovaný řetězec. Vyplnění výrazu interpolovaného řetězce je prázdné, očekával se výraz. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 181d79f304d..375a0367743 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -232,6 +232,11 @@ Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way. + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption standardmäßige Schnittstellenmembernutzung @@ -812,6 +817,11 @@ Für das „Paketverwaltungsfeature“ ist Sprachversion 5.0 oder höher erforderlich + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Ungültige interpolierte Zeichenfolge. Die Ausdrucksfüllung der interpolierten Zeichenfolge ist leer. Es wurde ein Ausdruck erwartet. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index b0d9d82dc97..138a15b5fd6 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -232,6 +232,11 @@ Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way. + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption consumo de miembros de interfaz predeterminados @@ -812,6 +817,11 @@ La característica de "administración de paquetes" requiere la versión de lenguaje 5.0 o superior + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Cadena interpolada no válida. Este relleno de expresión de cadena interpolada está vacío; se esperaba una expresión. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index e80c6033a52..6f01954b970 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -232,6 +232,11 @@ Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way. + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption consommation par défaut des membres d'interface @@ -812,6 +817,11 @@ La fonction « gestion des paquets » nécessite une version de langue 5.0 ou supérieure. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Chaîne interpolée non valide. Le remplissage de cette expression de chaîne interpolée est vide. Une expression est attendue. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index e40b57dae11..697bf76f64e 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -232,6 +232,11 @@ Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way. + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption utilizzo predefinito dei membri di interfaccia @@ -812,6 +817,11 @@ La funzionalità 'gestione pacchetti' richiede la versione del linguaggio 5.0 o superiore + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. La stringa interpolata non è valida. Il riempimento espressione di questa stringa interpolata è vuoto, mentre era prevista un'espressione. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 9f9830e214f..58b1902cf6e 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -232,6 +232,11 @@ Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way. + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption 既定のインターフェイス メンバーの消費 @@ -812,6 +817,11 @@ 'package management' (パッケージ管理) 機能には、言語バージョン 5.0 以降が必要です + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. 補間された文字列が無効です。この補間された文字列式の塗りつぶしが空です。式が必要です。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index f5b2130327e..28324acae71 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -232,6 +232,11 @@ Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way. + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption 기본 인터페이스 멤버 사용 @@ -812,6 +817,11 @@ '패키지 관리' 기능을 사용하려면 언어 버전 5.0 이상이 필요합니다. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. 보간된 문자열이 잘못되었습니다. 이 보간된 문자열 식 채우기가 비어 있는데, 식이 필요합니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 8ba98da9f2d..6f6c8daf320 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -232,6 +232,11 @@ Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way. + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption domyślne użycie składowej interfejsu @@ -812,6 +817,11 @@ Funkcja „Zarządzanie pakietami” wymaga języka w wersji 5.0 lub nowszej + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Nieprawidłowy ciąg interpolowany. Wyrażenie ciągu interpolowanego nie jest wypełnione, a jest oczekiwane. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index a9c5544273f..4517a79c5b6 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -232,6 +232,11 @@ Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way. + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption consumo de membro da interface padrão @@ -812,6 +817,11 @@ O recurso 'gerenciamento de pacotes' requer a versão 5.0 ou superior do idioma + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Cadeia de caracteres interpolada inválida. O preenchimento dessa expressão de cadeia de caracteres interpolada está vazio. Era esperada uma expressão. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 46e5d7ba3d9..77219d2c729 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -232,6 +232,11 @@ Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way. + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption использование элемента интерфейса по умолчанию @@ -812,6 +817,11 @@ Для функции управления пакетами требуется версия языка 5.0 или более поздняя + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Недопустимая интерполированная строка. Выражение этой интерполированной строки является пустым. Ожидается выражение. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 0bf209b346b..114ae90f526 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -232,6 +232,11 @@ Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way. + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption varsayılan arabirim üyesi tüketimi @@ -812,6 +817,11 @@ ‘Paket yönetimi’ özelliği, dil sürümü 5.0 veya üstünü gerektirir + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. Düz metin arasına kod eklenmiş dize geçersiz. Bu düz metin arasına kod eklenmiş dize ifade dolgusu boş. İfade bekleniyordu. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 978497120a0..4e2b6e434a6 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -232,6 +232,11 @@ Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way. + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption 默认接口成员消耗 @@ -812,6 +817,11 @@ “包管理”功能需要语言版本 5.0 或更高版本 + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. 内插字符串无效。此内插字符串表达式填充为空,应为表达式。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 770e440ac62..2c657dd8364 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -232,6 +232,11 @@ Raises warnings if a member or function has the 'TailCall' attribute, but is not being used in a tail recursive way. + + Constraint intersection on flexible types + Constraint intersection on flexible types + + default interface member consumption 預設介面成員使用 @@ -812,6 +817,11 @@ 「套件管理」功能需要語言版本 5.0 或更新版本 + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. + + Invalid interpolated string. This interpolated string expression fill is empty, an expression was expected. 插補字串無效。此插補字串運算式填滿為空白,必須有運算式。 From 10e0ad9bf34082342db88a65a8a3bcd87244b26d Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 2 Aug 2023 12:27:42 +0200 Subject: [PATCH 09/12] Adjust tests, unify trivia records after merge --- src/Compiler/SyntaxTree/SyntaxTree.fs | 2 +- src/Compiler/SyntaxTree/SyntaxTree.fsi | 2 +- src/Compiler/SyntaxTree/SyntaxTrivia.fs | 3 --- src/Compiler/SyntaxTree/SyntaxTrivia.fsi | 8 -------- .../Language/ConstraintIntersectionTests.fs | 4 ++-- 5 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index be5b98a2e94..46bd72d7567 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -458,7 +458,7 @@ type SynType = | FromParseError of range: range - | Intersection of typar: SynTypar option * types: SynType list * range: range * trivia: SynTypeIntersectionTrivia + | Intersection of typar: SynTypar option * types: SynType list * range: range * trivia: SynTyparDeclTrivia member x.Range = match x with diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 233f50dc41f..23869a93e60 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -529,7 +529,7 @@ type SynType = /// F# syntax: x: #I1 & #I2 /// F# syntax: x: 't & #I1 & #I2 /// Shorthand for x: 't when 't :> I1 and 't :> I2 - | Intersection of typar: SynTypar option * types: SynType list * range: range * trivia: SynTypeIntersectionTrivia + | Intersection of typar: SynTypar option * types: SynType list * range: range * trivia: SynTyparDeclTrivia /// Gets the syntax range of this construct member Range: range diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fs b/src/Compiler/SyntaxTree/SyntaxTrivia.fs index 688dc0348d2..a120b5e9c91 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fs +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fs @@ -401,9 +401,6 @@ type SynMemberSigMemberTrivia = static member Zero: SynMemberSigMemberTrivia = { GetSetKeywords = None } -[] -type SynTypeIntersectionTrivia = { AmpersandRanges: range list } - [] type SynTyparDeclTrivia = { diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi index b02494064ea..e41e7a037ce 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi @@ -516,14 +516,6 @@ type SynMemberSigMemberTrivia = static member Zero: SynMemberSigMemberTrivia -/// Represents additional information for SynType.Intersection -[] -type SynTypeIntersectionTrivia = - { - /// The syntax ranges of the `&` tokens - AmpersandRanges: range list - } - /// Represents additional information for SynTyparDecl [] type SynTyparDeclTrivia = diff --git a/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs index 2ac9b527e4b..0e0fee22505 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/ConstraintIntersectionTests.fs @@ -82,6 +82,6 @@ let y (f: #seq & System.IDisposable) = () |> typecheck |> shouldFail |> withDiagnostics [ - Error 3568, Line 2, Col 25, Line 2, Col 43, "Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." - Error 3568, Line 4, Col 23, Line 4, Col 41, "Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." + Error 3572, Line 2, Col 25, Line 2, Col 43, "Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." + Error 3572, Line 4, Col 23, Line 4, Col 41, "Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." ] \ No newline at end of file From 42bac636fb1b006311cbf60114770844351dbda2 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 2 Aug 2023 12:31:32 +0200 Subject: [PATCH 10/12] format --- src/Compiler/SyntaxTree/SyntaxTrivia.fs | 1 + src/Compiler/SyntaxTree/SyntaxTrivia.fsi | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fs b/src/Compiler/SyntaxTree/SyntaxTrivia.fs index a120b5e9c91..cf39c8c8818 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fs +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fs @@ -408,6 +408,7 @@ type SynTyparDeclTrivia = } static member Zero: SynTyparDeclTrivia = { AmpersandRanges = [] } + type SynMeasureConstantTrivia = { LessRange: range diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi index e41e7a037ce..d30816e697b 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi @@ -525,6 +525,7 @@ type SynTyparDeclTrivia = } static member Zero: SynTyparDeclTrivia + /// Represents additional information for SynConst.Measure [] type SynMeasureConstantTrivia = From b9a0ac8c8896e25bcb113a2944ca8b5859413792 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 2 Aug 2023 13:49:33 +0200 Subject: [PATCH 11/12] surface area update --- src/Compiler/SyntaxTree/SyntaxTrivia.fs | 1 + ...ervice.SurfaceArea.netstandard20.debug.bsl | 29 +++++++++++++++++-- ...vice.SurfaceArea.netstandard20.release.bsl | 10 ++----- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fs b/src/Compiler/SyntaxTree/SyntaxTrivia.fs index cf39c8c8818..999f93d29a5 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fs +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fs @@ -409,6 +409,7 @@ type SynTyparDeclTrivia = static member Zero: SynTyparDeclTrivia = { AmpersandRanges = [] } +[] type SynMeasureConstantTrivia = { LessRange: range diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index e71894b4682..8ecb80718d8 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -8434,13 +8434,17 @@ FSharp.Compiler.Syntax.SynTypar: FSharp.Compiler.Text.Range get_Range() FSharp.Compiler.Syntax.SynTypar: Int32 Tag FSharp.Compiler.Syntax.SynTypar: Int32 get_Tag() FSharp.Compiler.Syntax.SynTypar: System.String ToString() -FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTypar Item2 -FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTypar get_Item2() -FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTyparDecl NewSynTyparDecl(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Syntax.SynTypar) +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTypar get_typar() +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTypar typar +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.Syntax.SynTyparDecl NewSynTyparDecl(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Syntax.SynTypar, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia) +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia get_trivia() +FSharp.Compiler.Syntax.SynTyparDecl: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia trivia FSharp.Compiler.Syntax.SynTyparDecl: Int32 Tag FSharp.Compiler.Syntax.SynTyparDecl: Int32 get_Tag() FSharp.Compiler.Syntax.SynTyparDecl: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList] attributes FSharp.Compiler.Syntax.SynTyparDecl: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList] get_attributes() +FSharp.Compiler.Syntax.SynTyparDecl: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] get_intersectionConstraints() +FSharp.Compiler.Syntax.SynTyparDecl: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] intersectionConstraints FSharp.Compiler.Syntax.SynTyparDecl: System.String ToString() FSharp.Compiler.Syntax.SynTyparDecls+PostfixList: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynTyparDecls+PostfixList: FSharp.Compiler.Text.Range range @@ -8523,6 +8527,14 @@ FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Syntax.SynType ge FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Syntax.SynType innerType FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Text.Range range +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia get_trivia() +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia trivia +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.Text.Range get_range() +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.Text.Range range +FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] get_types() +FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] types +FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar] get_typar() +FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar] typar FSharp.Compiler.Syntax.SynType+LongIdent: FSharp.Compiler.Syntax.SynLongIdent get_longDotId() FSharp.Compiler.Syntax.SynType+LongIdent: FSharp.Compiler.Syntax.SynLongIdent longDotId FSharp.Compiler.Syntax.SynType+LongIdentApp: FSharp.Compiler.Syntax.SynLongIdent get_longDotId() @@ -8588,6 +8600,7 @@ FSharp.Compiler.Syntax.SynType+Tags: Int32 Array FSharp.Compiler.Syntax.SynType+Tags: Int32 FromParseError FSharp.Compiler.Syntax.SynType+Tags: Int32 Fun FSharp.Compiler.Syntax.SynType+Tags: Int32 HashConstraint +FSharp.Compiler.Syntax.SynType+Tags: Int32 Intersection FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdent FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdentApp FSharp.Compiler.Syntax.SynType+Tags: Int32 MeasurePower @@ -8623,6 +8636,7 @@ FSharp.Compiler.Syntax.SynType: Boolean IsArray FSharp.Compiler.Syntax.SynType: Boolean IsFromParseError FSharp.Compiler.Syntax.SynType: Boolean IsFun FSharp.Compiler.Syntax.SynType: Boolean IsHashConstraint +FSharp.Compiler.Syntax.SynType: Boolean IsIntersection FSharp.Compiler.Syntax.SynType: Boolean IsLongIdent FSharp.Compiler.Syntax.SynType: Boolean IsLongIdentApp FSharp.Compiler.Syntax.SynType: Boolean IsMeasurePower @@ -8642,6 +8656,7 @@ FSharp.Compiler.Syntax.SynType: Boolean get_IsArray() FSharp.Compiler.Syntax.SynType: Boolean get_IsFromParseError() FSharp.Compiler.Syntax.SynType: Boolean get_IsFun() FSharp.Compiler.Syntax.SynType: Boolean get_IsHashConstraint() +FSharp.Compiler.Syntax.SynType: Boolean get_IsIntersection() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdent() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdentApp() FSharp.Compiler.Syntax.SynType: Boolean get_IsMeasurePower() @@ -8661,6 +8676,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewArray(Int32, F FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFromParseError(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFun(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewHashConstraint(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewIntersection(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdent(FSharp.Compiler.Syntax.SynLongIdent) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdentApp(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynLongIdent, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewMeasurePower(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynRationalConst, FSharp.Compiler.Text.Range) @@ -8680,6 +8696,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Array FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+FromParseError FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Fun FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+HashConstraint +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Intersection FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+LongIdent FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+LongIdentApp FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+MeasurePower @@ -9889,6 +9906,12 @@ FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia: FSharp.Compiler.Text.Range BarRange FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia: FSharp.Compiler.Text.Range get_BarRange() FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynPatOrTrivia: Void .ctor(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia Zero +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia get_Zero() +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range] AmpersandRanges +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range] get_AmpersandRanges() +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia: Void .ctor(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynTypeDefnLeadingKeyword+And: FSharp.Compiler.Text.Range Item FSharp.Compiler.SyntaxTrivia.SynTypeDefnLeadingKeyword+And: FSharp.Compiler.Text.Range get_Item() FSharp.Compiler.SyntaxTrivia.SynTypeDefnLeadingKeyword+StaticType: FSharp.Compiler.Text.Range get_staticRange() diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index cdae44f47de..f3ce88c0a14 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -8527,8 +8527,8 @@ FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Syntax.SynType ge FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Syntax.SynType innerType FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Text.Range range -FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia get_trivia() -FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia trivia +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia get_trivia() +FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia trivia FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynType+Intersection: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynType+Intersection: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] get_types() @@ -8676,7 +8676,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewArray(Int32, F FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFromParseError(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFun(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewHashConstraint(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) -FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewIntersection(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia) +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewIntersection(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynTypar], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTyparDeclTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdent(FSharp.Compiler.Syntax.SynLongIdent) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdentApp(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynLongIdent, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewMeasurePower(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynRationalConst, FSharp.Compiler.Text.Range) @@ -9970,10 +9970,6 @@ FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: FSharp.Compiler.Text.Range ArrowR FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: FSharp.Compiler.Text.Range get_ArrowRange() FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: Void .ctor(FSharp.Compiler.Text.Range) -FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range] AmpersandRanges -FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range] get_AmpersandRanges() -FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynTypeIntersectionTrivia: Void .ctor(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: FSharp.Compiler.Text.Range OrKeyword FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: FSharp.Compiler.Text.Range get_OrKeyword() FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: System.String ToString() From 08fe4d96d9e00750c68b18627831c3d2e0c763f8 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 2 Aug 2023 14:01:50 +0200 Subject: [PATCH 12/12] syntax tests updated --- .../SyntaxTree/SynTyparDecl/Constraint intersection 01.fs.bsl | 2 +- .../data/SyntaxTree/SynType/Constraint intersection 01.fs.bsl | 2 +- .../data/SyntaxTree/SynType/Constraint intersection 02.fs.bsl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/service/data/SyntaxTree/SynTyparDecl/Constraint intersection 01.fs.bsl b/tests/service/data/SyntaxTree/SynTyparDecl/Constraint intersection 01.fs.bsl index 96d2a16e16c..bc10e55147e 100644 --- a/tests/service/data/SyntaxTree/SynTyparDecl/Constraint intersection 01.fs.bsl +++ b/tests/service/data/SyntaxTree/SynTyparDecl/Constraint intersection 01.fs.bsl @@ -62,7 +62,7 @@ ImplFile ([[SynArgInfo ([], false, None)]; [SynArgInfo ([], false, Some x); SynArgInfo ([], false, Some y)]], - SynArgInfo ([], false, None)), None), + SynArgInfo ([], false, None)), None, None), LongIdent (SynLongIdent ([_; G], [(4,12--4,13)], [None; None]), None, diff --git a/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs.bsl b/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs.bsl index 64e8fd7c7a8..937da0bbbad 100644 --- a/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs.bsl +++ b/tests/service/data/SyntaxTree/SynType/Constraint intersection 01.fs.bsl @@ -13,7 +13,7 @@ ImplFile (None, SynValInfo ([[SynArgInfo ([], false, Some f)]], - SynArgInfo ([], false, None)), None), + SynArgInfo ([], false, None)), None, None), LongIdent (SynLongIdent ([y], [], [None]), None, None, Pats diff --git a/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs.bsl b/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs.bsl index 039915cb522..443d1b2c50b 100644 --- a/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs.bsl +++ b/tests/service/data/SyntaxTree/SynType/Constraint intersection 02.fs.bsl @@ -13,7 +13,7 @@ ImplFile (None, SynValInfo ([[SynArgInfo ([], false, Some f)]], - SynArgInfo ([], false, None)), None), + SynArgInfo ([], false, None)), None, None), LongIdent (SynLongIdent ([y], [], [None]), None, None, Pats