From 83cc0e4f5a958da008706f2448fe3ee3036df145 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 16 Jun 2023 20:49:47 +0200 Subject: [PATCH 01/20] internalerror with MakeValueAssign fixed? --- .../Language/RegressionTests.fs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/RegressionTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/RegressionTests.fs index 81e55158788..68b710f85ae 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/RegressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/RegressionTests.fs @@ -19,3 +19,13 @@ type TestItemSeq = |> compile |> withErrorCodes [39] |> ignore + + + [] + let ``Member val regression - not allowed without primary constructor`` () = + Fs """module Test + type Bad3 = + member val X = 1 + 1 """ + |> typecheck + |> shouldFail + |> withDiagnostics [] From 59d1b41dc42e83b12468399047b2c523f451dee5 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 25 Jul 2023 16:34:21 +0200 Subject: [PATCH 02/20] Adding cancellation suppot for lexing and parsing --- src/Compiler/Service/FSharpCheckerResults.fs | 35 ++++++++++++++----- src/Compiler/Service/FSharpCheckerResults.fsi | 6 ++-- src/Compiler/Service/service.fs | 16 ++++++--- src/Compiler/SyntaxTree/LexHelpers.fs | 4 ++- 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index 3fbfe27bed8..f797ca89e3c 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -2329,7 +2329,7 @@ module internal ParseAndCheckFile = IndentationAwareSyntaxStatus(indentationSyntaxStatus, true) - let createLexerFunction fileName options lexbuf (errHandler: DiagnosticsHandler) = + let createLexerFunction fileName options lexbuf (errHandler: DiagnosticsHandler) (ct: CancellationToken) = let indentationSyntaxStatus = getLightSyntaxStatus fileName options // If we're editing a script then we define INTERACTIVE otherwise COMPILED. @@ -2357,12 +2357,25 @@ module internal ParseAndCheckFile = let tokenizer = LexFilter.LexFilter(indentationSyntaxStatus, options.CompilingFSharpCore, Lexer.token lexargs true, lexbuf, false) - (fun _ -> tokenizer.GetToken()) + if ct.CanBeCanceled then + (fun _ -> + ct.ThrowIfCancellationRequested() + tokenizer.GetToken()) + else + (fun _ -> tokenizer.GetToken()) let createLexbuf langVersion strictIndentation sourceText = UnicodeLexing.SourceTextAsLexbuf(true, LanguageVersion(langVersion), strictIndentation, sourceText) - let matchBraces (sourceText: ISourceText, fileName, options: FSharpParsingOptions, userOpName: string, suggestNamesForErrors: bool) = + let matchBraces + ( + sourceText: ISourceText, + fileName, + options: FSharpParsingOptions, + userOpName: string, + suggestNamesForErrors: bool, + ct: CancellationToken + ) = // Make sure there is an DiagnosticsLogger installed whenever we do stuff that might record errors, even if we ultimately ignore the errors let delayedLogger = CapturingDiagnosticsLogger("matchBraces") use _ = UseDiagnosticsLogger delayedLogger @@ -2376,7 +2389,7 @@ module internal ParseAndCheckFile = let errHandler = DiagnosticsHandler(false, fileName, options.DiagnosticOptions, sourceText, suggestNamesForErrors, false) - let lexfun = createLexerFunction fileName options lexbuf errHandler + let lexfun = createLexerFunction fileName options lexbuf errHandler ct let parenTokensBalance t1 t2 = match t1, t2 with @@ -2469,7 +2482,8 @@ module internal ParseAndCheckFile = userOpName: string, suggestNamesForErrors: bool, flatErrors: bool, - identCapture: bool + identCapture: bool, + ct: CancellationToken ) = Trace.TraceInformation("FCS: {0}.{1} ({2})", userOpName, "parseFile", fileName) @@ -2486,7 +2500,7 @@ module internal ParseAndCheckFile = let parseResult = usingLexbufForParsing (createLexbuf options.LangVersionText options.StrictIndentation sourceText, fileName) (fun lexbuf -> - let lexfun = createLexerFunction fileName options lexbuf errHandler + let lexfun = createLexerFunction fileName options lexbuf errHandler ct let isLastCompiland = fileName.Equals(options.LastFileName, StringComparison.CurrentCultureIgnoreCase) @@ -2506,7 +2520,9 @@ module internal ParseAndCheckFile = identCapture, Some userOpName ) - with e -> + with + | :? OperationCanceledException -> reraise () + | e -> errHandler.DiagnosticsLogger.StopProcessingRecovery e range0 // don't re-raise any exceptions, we must return None. EmptyParsedInput(fileName, (isLastCompiland, isExe))) @@ -3322,6 +3338,8 @@ type FsiInteractiveChecker(legacyReferenceResolver, tcConfig: TcConfig, tcGlobal let parsingOptions = FSharpParsingOptions.FromTcConfig(tcConfig, [| fileName |], true) + let! ct = Cancellable.token () + let parseErrors, parsedInput, anyErrors = ParseAndCheckFile.parseFile ( sourceText, @@ -3330,7 +3348,8 @@ type FsiInteractiveChecker(legacyReferenceResolver, tcConfig: TcConfig, tcGlobal userOpName, suggestNamesForErrors, tcConfig.flatErrors, - tcConfig.captureIdentifiersWhenParsing + tcConfig.captureIdentifiersWhenParsing, + ct ) let dependencyFiles = [||] // interactions have no dependencies diff --git a/src/Compiler/Service/FSharpCheckerResults.fsi b/src/Compiler/Service/FSharpCheckerResults.fsi index a301f3697d8..c4ba903faf1 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fsi +++ b/src/Compiler/Service/FSharpCheckerResults.fsi @@ -544,7 +544,8 @@ module internal ParseAndCheckFile = userOpName: string * suggestNamesForErrors: bool * flatErrors: bool * - identCapture: bool -> + identCapture: bool * + ct: CancellationToken -> FSharpDiagnostic[] * ParsedInput * bool val matchBraces: @@ -552,7 +553,8 @@ module internal ParseAndCheckFile = fileName: string * options: FSharpParsingOptions * userOpName: string * - suggestNamesForErrors: bool -> + suggestNamesForErrors: bool * + ct: CancellationToken -> (range * range)[] // An object to typecheck source in a given typechecking environment. diff --git a/src/Compiler/Service/service.fs b/src/Compiler/Service/service.fs index a079864c1a9..6727c11af63 100644 --- a/src/Compiler/Service/service.fs +++ b/src/Compiler/Service/service.fs @@ -506,6 +506,7 @@ type BackgroundCompiler | Some res -> return res | None -> Interlocked.Increment(&actualParseFileCount) |> ignore + let! ct = Async.CancellationToken let parseDiagnostics, parseTree, anyErrors = ParseAndCheckFile.parseFile ( @@ -515,15 +516,18 @@ type BackgroundCompiler userOpName, suggestNamesForErrors, flatErrors, - captureIdentifiersWhenParsing + captureIdentifiersWhenParsing, + ct ) let res = FSharpParseFileResults(parseDiagnostics, parseTree, anyErrors, options.SourceFiles) parseCacheLock.AcquireLock(fun ltok -> parseFileCache.Set(ltok, (fileName, hash, options), res)) return res else + let! ct = Async.CancellationToken + let parseDiagnostics, parseTree, anyErrors = - ParseAndCheckFile.parseFile (sourceText, fileName, options, userOpName, false, flatErrors, captureIdentifiersWhenParsing) + ParseAndCheckFile.parseFile (sourceText, fileName, options, userOpName, false, flatErrors, captureIdentifiersWhenParsing, ct) return FSharpParseFileResults(parseDiagnostics, parseTree, anyErrors, options.SourceFiles) } @@ -775,6 +779,7 @@ type BackgroundCompiler FSharpParsingOptions.FromTcConfig(builder.TcConfig, Array.ofList builder.SourceFiles, options.UseScriptResolutionRules) GraphNode.SetPreferredUILang tcPrior.TcConfig.preferredUiLang + let! ct = NodeCode.CancellationToken let parseDiagnostics, parseTree, anyErrors = ParseAndCheckFile.parseFile ( @@ -784,7 +789,8 @@ type BackgroundCompiler userOpName, suggestNamesForErrors, builder.TcConfig.flatErrors, - captureIdentifiersWhenParsing + captureIdentifiersWhenParsing, + ct ) let parseResults = @@ -1433,8 +1439,10 @@ type FSharpChecker match braceMatchCache.TryGet(AnyCallerThread, (fileName, hash, options)) with | Some res -> return res | None -> + let! ct = Async.CancellationToken + let res = - ParseAndCheckFile.matchBraces (sourceText, fileName, options, userOpName, suggestNamesForErrors) + ParseAndCheckFile.matchBraces (sourceText, fileName, options, userOpName, suggestNamesForErrors, ct) braceMatchCache.Set(AnyCallerThread, (fileName, hash, options), res) return res diff --git a/src/Compiler/SyntaxTree/LexHelpers.fs b/src/Compiler/SyntaxTree/LexHelpers.fs index eb204fc18b1..02d4da364d4 100644 --- a/src/Compiler/SyntaxTree/LexHelpers.fs +++ b/src/Compiler/SyntaxTree/LexHelpers.fs @@ -105,7 +105,9 @@ let reusingLexbufForParsing lexbuf f = try f () - with e -> + with + | :? OperationCanceledException -> reraise () + | e -> raise ( WrappedError( e, From 151e108f1c5feb649369bb7fc48d7001de2f811e Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 25 Jul 2023 16:40:41 +0200 Subject: [PATCH 03/20] x --- .../Language/RegressionTests.fs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/RegressionTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/RegressionTests.fs index 5298fa87f2c..b29311ba33b 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/RegressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/RegressionTests.fs @@ -19,13 +19,3 @@ type TestItemSeq = |> compile |> withErrorCodes [39] |> ignore - - - [] - let ``Member val regression - not allowed without primary constructor`` () = - Fs """module Test - type Bad3 = - member val X = 1 + 1 """ - |> typecheck - |> shouldFail - |> withDiagnostics [] From 38d7f366a2355fc1a5f8d11566316aef4201488b Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 27 Jul 2023 13:18:55 +0200 Subject: [PATCH 04/20] tests covering non working case, fallback fix (still kind of hack) --- src/Compiler/CodeGen/EraseUnions.fs | 15 ++- .../Types/UnionTypes/UnionStructTypes.fs | 121 +++++++++++------- 2 files changed, 89 insertions(+), 47 deletions(-) diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index 5dcd60c9a14..7d9f5e814cc 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -334,6 +334,8 @@ let mkTagDiscriminate ilg cuspec _baseTy cidx = let mkTagDiscriminateThen ilg cuspec cidx after = [ mkGetTag ilg cuspec; mkLdcInt32 cidx ] @ mkCeqThen after +let basicTypes (ilg:ILGlobals) = [|ilg.typ_Bool;ilg.typ_Byte;ilg.typ_SByte;ilg.typ_Char;ilg.typ_Int16;ilg.typ_Int32;ilg.typ_UInt16;ilg.typ_UInt32 |] + /// The compilation for struct unions relies on generating a set of constructors. /// If necessary some fake types are added to the constructor parameters to distinguish the signature. let rec extraTysAndInstrsForStructCtor (ilg: ILGlobals) cidx = @@ -345,9 +347,15 @@ let rec extraTysAndInstrsForStructCtor (ilg: ILGlobals) cidx = | 4 -> [ ilg.typ_Int16 ], [ mkLdcInt32 0 ] | 5 -> [ ilg.typ_Int32 ], [ mkLdcInt32 0 ] | 6 -> [ ilg.typ_UInt16 ], [ mkLdcInt32 0 ] + | 7 -> [ ilg.typ_UInt32 ], [ mkLdcInt32 0 ] | _ -> - let tys, instrs = extraTysAndInstrsForStructCtor ilg (cidx - 7) - (ilg.typ_UInt32 :: tys, mkLdcInt32 0 :: instrs) + let mod8 = cidx % 8 + let div8 = cidx / 8 + + let matchingType = (basicTypes ilg)[mod8] + + let tys, instrs = extraTysAndInstrsForStructCtor ilg (div8) + (matchingType :: tys, mkLdcInt32 0 :: instrs) let takesExtraParams (alts: IlxUnionCase[]) = alts.Length > 1 @@ -389,6 +397,9 @@ let convNewDataInstrInternal ilg cuspec cidx = let ctorFieldTys = alt.FieldTypes |> Array.toList + let justTomasTestingThings = + [] + let extraTys, extraInstrs = if takesExtraParams cuspec.AlternativesArray then extraTysAndInstrsForStructCtor ilg cidx diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs index b22653ee742..f515f77ca7e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs @@ -14,7 +14,7 @@ type StructUnion = | A | B of string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -26,7 +26,7 @@ type StructUnion = | A | B of b: string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -39,7 +39,7 @@ type StructUnion = | B of string | C """ - |> compile + |> typecheck |> shouldSucceed [] @@ -52,7 +52,7 @@ type StructUnion = | B of b: string | C """ - |> compile + |> typecheck |> shouldSucceed [] @@ -65,7 +65,7 @@ type StructUnion = | B of b: string | C of bool """ - |> compile + |> typecheck |> shouldSucceed [] @@ -78,7 +78,7 @@ type StructUnion = | B | C of bool """ - |> compile + |> typecheck |> shouldSucceed [] @@ -90,7 +90,7 @@ type NotATree = | Empty | Children of struct (int * string) """ - |> compile + |> typecheck |> shouldSucceed [] @@ -102,7 +102,7 @@ type NotATree = | Empty | Children of struct (int * string) """ - |> compile + |> typecheck |> shouldSucceed [] @@ -114,7 +114,7 @@ type NotATree = | Empty | Children of a: struct (int * string) """ - |> compile + |> typecheck |> shouldSucceed [] @@ -127,7 +127,7 @@ type StructUnion = | B of string | C of string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 15, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -144,7 +144,7 @@ type StructUnion = | B of string | C of string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 13, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -161,7 +161,7 @@ type StructUnion = | B of b: string | C of string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 15, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -178,7 +178,7 @@ type StructUnion = | B of b: string | C of string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -191,7 +191,7 @@ type StructUnion = | B of b: string | C of c: string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -203,7 +203,7 @@ type StructUnion = | A of Item: int | B of string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -218,7 +218,7 @@ type StructUnion = | A of Item: int | B of Item: string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -233,7 +233,7 @@ type StructUnion = | A of Item: int | B of item : string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -245,7 +245,7 @@ type StructUnion = | A of item: int | B of item: string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -260,7 +260,7 @@ type StructUnion = | A of Item: int * string | B of string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -276,7 +276,7 @@ type StructUnion = | A of Item: int * item: string | B of string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -292,7 +292,7 @@ type StructUnion = | A of Item: int * item: string | B of item: string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -308,7 +308,7 @@ type StructUnion = | A of Item: int * string | B of item: string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -320,7 +320,7 @@ type StructUnion = | A of item: string * int | B of string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -332,7 +332,7 @@ type StructUnion = | A of item: string * item: int | B of string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3176, Line 5, Col 27, Line 5, Col 31, "Named field 'item' is used more than once.") @@ -347,7 +347,7 @@ type StructUnion = | A of Item: string * Item: int | B of string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3176, Line 5, Col 27, Line 5, Col 31, "Named field 'Item' is used more than once.") @@ -360,7 +360,7 @@ namespace Foo [] type StructUnion = A of a: int | B of b:string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -372,7 +372,7 @@ type StructUnion = | A of a: int | B of b: string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -384,7 +384,7 @@ type StructUnion = | A of a: int * a1: string | B of string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -396,7 +396,7 @@ type StructUnion = | A of int * string | B of string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -408,7 +408,7 @@ type StructUnion = | A of a: int * string | B of string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -420,7 +420,7 @@ type StructUnion = | A of int * a1: string | B of string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -432,7 +432,7 @@ type StructUnion = | A of int | B of b: string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -444,7 +444,7 @@ type StructUnion = | A of a: int * a1: string | B of b: string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -454,7 +454,7 @@ namespace Foo [] type StructUnion = A of int | B of string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 4, Col 25, Line 4, Col 28, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -469,7 +469,7 @@ type StructUnion = | A of a: int | B of string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -482,7 +482,7 @@ type StructUnion = | B of string | C of string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 15, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -500,7 +500,7 @@ type StructUnion = | B of string | C of string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 13, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -518,7 +518,7 @@ type StructUnion = | B of string | C of string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 15, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -536,7 +536,7 @@ type StructUnion = | B of string | C of string """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 13, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -554,7 +554,7 @@ type StructUnion = | B of b: string | C of string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -567,7 +567,7 @@ type StructUnion = | B of string | C of c: string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -580,7 +580,7 @@ type StructUnion = | B of b: string | C of string """ - |> compile + |> typecheck |> shouldSucceed [] @@ -593,7 +593,7 @@ type StructUnion = | B of string * b: string | C of c: string * string * c3: int """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 13, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") @@ -614,7 +614,7 @@ type StructUnion = | B of b1: string * b: string | C of c: string * c1: string * c3: int """ - |> compile + |> typecheck |> shouldSucceed [] @@ -624,8 +624,39 @@ namespace Foo [] type StructUnion = A of X:int | B of Y:StructUnion """ - |> compile + |> typecheck |> shouldFail |> withDiagnostics [ (Error 954, Line 4, Col 6, Line 4, Col 17, "This type definition involves an immediate cyclic reference through a struct field or inheritance relation") ] + + [] + [] + [] + [] + [] + [] + [] + let ``Struct DU compilation does not embarassingly fail when having many data-less cases`` (countOfCases:int) = + let codeSb = + System.Text.StringBuilder(""" +module Foo +[] +type StructUnion = +""" ) + + for i=1 to countOfCases do + codeSb.AppendLine($" | Case{i}") |> ignore + + codeSb.AppendLine($""" +[] +let main _argv = + printf "%%A" Case{countOfCases} + 0""") |> ignore + + Fs (codeSb.ToString()) + |> asExe + |> compile + |> run + |> shouldSucceed + |> verifyOutput $"Case{countOfCases}" \ No newline at end of file From ed17a331237aad0019ddf246e67f91c00fff0cea Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 27 Jul 2023 16:35:42 +0200 Subject: [PATCH 05/20] Change construction methods for [] unions to enable creating > 49 of cases, simplify IL --- src/Compiler/CodeGen/EraseUnions.fs | 198 ++++++++---------- .../Types/UnionTypes/UnionStructTypes.fs | 101 +++++++-- 2 files changed, 179 insertions(+), 120 deletions(-) diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index 7d9f5e814cc..700df5bc68c 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -278,6 +278,9 @@ let mkRuntimeTypeDiscriminateThen ilg avoidHelpers cuspec alt altName altTy afte let mkGetTagFromField ilg cuspec baseTy = mkNormalLdfld (refToFieldInTy baseTy (mkTagFieldId ilg cuspec)) +let mkSetTagToField ilg cuspec baseTy = + mkNormalStfld (refToFieldInTy baseTy (mkTagFieldId ilg cuspec)) + let adjustFieldName hasHelpers nm = match hasHelpers, nm with | SpecialFSharpListHelpers, "Head" -> "HeadOrDefault" @@ -334,37 +337,6 @@ let mkTagDiscriminate ilg cuspec _baseTy cidx = let mkTagDiscriminateThen ilg cuspec cidx after = [ mkGetTag ilg cuspec; mkLdcInt32 cidx ] @ mkCeqThen after -let basicTypes (ilg:ILGlobals) = [|ilg.typ_Bool;ilg.typ_Byte;ilg.typ_SByte;ilg.typ_Char;ilg.typ_Int16;ilg.typ_Int32;ilg.typ_UInt16;ilg.typ_UInt32 |] - -/// The compilation for struct unions relies on generating a set of constructors. -/// If necessary some fake types are added to the constructor parameters to distinguish the signature. -let rec extraTysAndInstrsForStructCtor (ilg: ILGlobals) cidx = - match cidx with - | 0 -> [ ilg.typ_Bool ], [ mkLdcInt32 0 ] - | 1 -> [ ilg.typ_Byte ], [ mkLdcInt32 0 ] - | 2 -> [ ilg.typ_SByte ], [ mkLdcInt32 0 ] - | 3 -> [ ilg.typ_Char ], [ mkLdcInt32 0 ] - | 4 -> [ ilg.typ_Int16 ], [ mkLdcInt32 0 ] - | 5 -> [ ilg.typ_Int32 ], [ mkLdcInt32 0 ] - | 6 -> [ ilg.typ_UInt16 ], [ mkLdcInt32 0 ] - | 7 -> [ ilg.typ_UInt32 ], [ mkLdcInt32 0 ] - | _ -> - let mod8 = cidx % 8 - let div8 = cidx / 8 - - let matchingType = (basicTypes ilg)[mod8] - - let tys, instrs = extraTysAndInstrsForStructCtor ilg (div8) - (matchingType :: tys, mkLdcInt32 0 :: instrs) - -let takesExtraParams (alts: IlxUnionCase[]) = - alts.Length > 1 - && (alts |> Array.exists (fun d -> d.FieldDefs.Length > 0) - || - // Check if not all lengths are distinct - alts |> Array.countBy (fun d -> d.FieldDefs.Length) |> Array.length - <> alts.Length) - let convNewDataInstrInternal ilg cuspec cidx = let alt = altOfUnionSpec cuspec cidx let altTy = tyForAlt cuspec alt @@ -388,29 +360,11 @@ let convNewDataInstrInternal ilg cuspec cidx = instrs @ [ mkNormalNewobj (mkILCtorMethSpecForTy (baseTy, (ctorFieldTys @ tagfields))) ] elif cuspecRepr.RepresentAlternativeAsStructValue cuspec then + // Structs with fields should be created using maker methods (mkMakerName), only field-less cases are created this way + assert (alt.IsNullary) let baseTy = baseTyOfUnionSpec cuspec - - let instrs, tagfields = - match cuspecRepr.DiscriminationTechnique cuspec with - | IntegerTag -> [ mkLdcInt32 cidx ], [ mkTagFieldType ilg cuspec ] - | _ -> [], [] - - let ctorFieldTys = alt.FieldTypes |> Array.toList - - let justTomasTestingThings = - [] - - let extraTys, extraInstrs = - if takesExtraParams cuspec.AlternativesArray then - extraTysAndInstrsForStructCtor ilg cidx - else - [], [] - - instrs - @ extraInstrs - @ [ - mkNormalNewobj (mkILCtorMethSpecForTy (baseTy, (ctorFieldTys @ tagfields @ extraTys))) - ] + let tagField = [ mkTagFieldType ilg cuspec ] + [ mkLdcInt32 cidx; mkNormalNewobj (mkILCtorMethSpecForTy (baseTy, tagField)) ] else [ mkNormalNewobj (mkILCtorMethSpecForTy (altTy, Array.toList alt.FieldTypes)) ] @@ -425,6 +379,24 @@ let mkNewData ilg (cuspec, cidx) = let alt = altOfUnionSpec cuspec cidx let altName = alt.Name let baseTy = baseTyOfUnionSpec cuspec + + let viaMakerCall () = + [ + mkNormalCall ( + mkILNonGenericStaticMethSpecInTy ( + baseTy, + mkMakerName cuspec altName, + Array.toList alt.FieldTypes, + constFormalFieldTy baseTy + ) + ) + ] + + let viaGetAltNameProperty () = + [ + mkNormalCall (mkILNonGenericStaticMethSpecInTy (baseTy, "get_" + altName, [], constFormalFieldTy baseTy)) + ] + // If helpers exist, use them match cuspec.HasHelpers with | AllHelpers @@ -433,30 +405,13 @@ let mkNewData ilg (cuspec, cidx) = if cuspecRepr.RepresentAlternativeAsNull(cuspec, alt) then [ AI_ldnull ] elif alt.IsNullary then - [ - mkNormalCall (mkILNonGenericStaticMethSpecInTy (baseTy, "get_" + altName, [], constFormalFieldTy baseTy)) - ] + viaGetAltNameProperty () else - [ - mkNormalCall ( - mkILNonGenericStaticMethSpecInTy ( - baseTy, - mkMakerName cuspec altName, - Array.toList alt.FieldTypes, - constFormalFieldTy baseTy - ) - ) - ] + viaMakerCall () - | NoHelpers -> - if cuspecRepr.MaintainPossiblyUniqueConstantFieldForAlternative(cuspec, alt) then - // This method is only available if not AllHelpers. It fetches the unique object for the alternative - // without exposing direct access to the underlying field - [ - mkNormalCall (mkILNonGenericStaticMethSpecInTy (baseTy, "get_" + altName, [], constFormalFieldTy baseTy)) - ] - else - convNewDataInstrInternal ilg cuspec cidx + | NoHelpers when (not alt.IsNullary) && cuspecRepr.RepresentAlternativeAsStructValue cuspec -> viaMakerCall () + | NoHelpers when cuspecRepr.MaintainPossiblyUniqueConstantFieldForAlternative(cuspec, alt) -> viaGetAltNameProperty () + | NoHelpers -> convNewDataInstrInternal ilg cuspec cidx let mkIsData ilg (avoidHelpers, cuspec, cidx) = let alt = altOfUnionSpec cuspec cidx @@ -927,13 +882,35 @@ let convAlternativeDef [ nullaryMeth ], [ nullaryProp ] else - let ilInstrs = - [ - for i in 0 .. fields.Length - 1 do - mkLdarg (uint16 i) - yield! convNewDataInstrInternal g.ilg cuspec num - ] - |> nonBranchingInstrsToCode + let locals, ilInstrs = + if repr.RepresentAlternativeAsStructValue info then + let local = mkILLocal baseTy None + let ldloca = I_ldloca(0us) + + let ilInstrs = + [ + ldloca + ILInstr.I_initobj baseTy + ldloca + mkLdcInt32 num + mkSetTagToField g.ilg cuspec baseTy + for i in 0 .. fields.Length - 1 do + ldloca + mkLdarg (uint16 i) + mkNormalStfld (mkILFieldSpecInTy (baseTy, fields[i].LowerName, fields[i].Type)) + mkLdloc 0us + ] + + [ local ], ilInstrs + else + let ilInstrs = + [ + for i in 0 .. fields.Length - 1 do + mkLdarg (uint16 i) + yield! convNewDataInstrInternal g.ilg cuspec num + ] + + [], ilInstrs let mdef = mkILNonGenericStaticMethod ( @@ -943,7 +920,7 @@ let convAlternativeDef |> Array.map (fun fd -> mkILParamNamed (fd.LowerName, fd.Type)) |> Array.toList, mkILReturn baseTy, - mkMethodBody (true, [], fields.Length, ilInstrs, attr, imports) + mkMethodBody (true, locals, fields.Length, nonBranchingInstrsToCode ilInstrs, attr, imports) ) |> addMethodGeneratedAttrs |> addAltAttribs @@ -1230,9 +1207,20 @@ let mkClassUnionDef let isStruct = td.IsStruct + let ctorAccess = + if cuspec.HasHelpers = AllHelpers then + ILMemberAccess.Assembly + else + cud.UnionCasesAccessibility + let selfFields, selfMeths, selfProps = [ + let minNullaryIdx = + cud.UnionCases + |> Array.tryFindIndex (fun t -> t.IsNullary) + |> Option.defaultValue -1 + for cidx, alt in Array.indexed cud.UnionCases do if repr.RepresentAlternativeAsFreshInstancesOfRootClass(info, alt) @@ -1249,31 +1237,25 @@ let mkClassUnionDef | None -> Some g.ilg.typ_Object.TypeSpec | Some ilTy -> Some ilTy.TypeSpec - let extraParamsForCtor = - if isStruct && takesExtraParams cud.UnionCases then - let extraTys, _extraInstrs = extraTysAndInstrsForStructCtor g.ilg cidx - List.map mkILParamAnon extraTys - else - [] - - let ctorAccess = - (if cuspec.HasHelpers = AllHelpers then - ILMemberAccess.Assembly - else - cud.UnionCasesAccessibility) - let ctor = - (mkILSimpleStorageCtor ( - baseInit, - baseTy, - extraParamsForCtor, - (fields @ tagFieldsInObject), - ctorAccess, - cud.DebugPoint, - cud.DebugImports - )) - .With(customAttrs = mkILCustomAttrs [ GetDynamicDependencyAttribute g 0x660 baseTy ]) - |> addMethodGeneratedAttrs + // Structs with fields are created using static makers methods + // Structs without fields can share constructor for the 'tag' value, we just create one + if isStruct && not (cidx = minNullaryIdx) then + [] + else + [ + (mkILSimpleStorageCtor ( + baseInit, + baseTy, + [], + (fields @ tagFieldsInObject), + ctorAccess, + cud.DebugPoint, + cud.DebugImports + )) + .With(customAttrs = mkILCustomAttrs [ GetDynamicDependencyAttribute g 0x660 baseTy ]) + |> addMethodGeneratedAttrs + ] let props, meths = mkMethodsAndPropertiesForFields @@ -1285,7 +1267,7 @@ let mkClassUnionDef baseTy alt.FieldDefs - yield (fields, ([ ctor ] @ meths), props) + yield (fields, (ctor @ meths), props) ] |> List.unzip3 |> (fun (a, b, c) -> List.concat a, List.concat b, List.concat c) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs index f515f77ca7e..70fbc633a1b 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs @@ -630,33 +630,110 @@ type StructUnion = A of X:int | B of Y:StructUnion (Error 954, Line 4, Col 6, Line 4, Col 17, "This type definition involves an immediate cyclic reference through a struct field or inheritance relation") ] - [] - [] - [] - [] - [] - [] - [] - let ``Struct DU compilation does not embarassingly fail when having many data-less cases`` (countOfCases:int) = + + let createMassiveStructDuProgram countOfCases = let codeSb = System.Text.StringBuilder(""" module Foo -[] +[] type StructUnion = """ ) + + let basicTypes = [|"";"";"int";"string";"byte";"System.Uri";"int[]";"option";"voption";"System.Uri[]"|] for i=1 to countOfCases do - codeSb.AppendLine($" | Case{i}") |> ignore + let t = basicTypes[i%basicTypes.Length] + if t = "" then + codeSb.AppendLine($" | Case{i}") |> ignore + else + codeSb.AppendLine($" | Case{i} of field1_{i}:{t} * field2_{i}:{t}") |> ignore codeSb.AppendLine($""" [] let main _argv = - printf "%%A" Case{countOfCases} + printf "%%A" (Case{countOfCases} (Unchecked.defaultof<_>,Unchecked.defaultof<_>)) 0""") |> ignore Fs (codeSb.ToString()) + + + [] + [] + [] + [] + let ``Struct DU compilation does not embarassingly fail when having many data-less cases`` (countOfCases:int) = + createMassiveStructDuProgram countOfCases |> asExe |> compile |> run |> shouldSucceed - |> verifyOutput $"Case{countOfCases}" \ No newline at end of file + |> verifyOutput $"Case{countOfCases} (null, null)" + + + [] + let ``Struct DU compilation - have a look at IL for massive cases`` () = + createMassiveStructDuProgram 15 + |> asExe + |> compile + |> verifyIL [(*This is case-agnostic constructor used for data-less cases, just fills in the _tag property*)""" + instance void .ctor(int32 _tag) cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 0F 46 6F 6F 2B 53 74 72 75 63 + 74 55 6E 69 6F 6E 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 Foo/StructUnion::_tag + IL_0007: ret + } """;(*This is getter for a data-less case, just calling into the constructor above*)""" + get_Case11() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 0A 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: newobj instance void Foo/StructUnion::.ctor(int32) + IL_0007: ret + }""";(*This is a 'maker method' New{CaseName} used for cases which do have fields associated with them, + the _tag gets initialized*)""" + NewCase3(string _field1_3, + string _field2_3) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 02 00 00 00 00 00 ) + + .maxstack 2 + .locals init (valuetype Foo/StructUnion V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj Foo/StructUnion + IL_0008: ldloca.s V_0 + IL_000a: ldc.i4.2 + IL_000b: stfld int32 Foo/StructUnion::_tag + IL_0010: ldloca.s V_0 + IL_0012: ldarg.0 + IL_0013: stfld string Foo/StructUnion::_field1_3 + IL_0018: ldloca.s V_0 + IL_001a: ldarg.1 + IL_001b: stfld string Foo/StructUnion::_field2_3 + IL_0020: ldloc.0 + IL_0021: ret + } + + .method public hidebysig instance bool + get_IsCase3() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 Foo/StructUnion::get_Tag() + IL_0006: ldc.i4.2 + IL_0007: ceq + IL_0009: ret + } +"""] From 8a9aa381a0dfcebeae6b90327f7625400f626621 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 28 Jul 2023 10:50:11 +0200 Subject: [PATCH 06/20] add failing cases --- .../Types/UnionTypes/UnionStructTypes.fs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs index 70fbc633a1b..485aa5ac087 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs @@ -670,6 +670,20 @@ let main _argv = |> verifyOutput $"Case{countOfCases} (null, null)" + [] + let ``Single case DU keeps working`` () = + Fsx """ +namespace Foo +[] +type TagOnlyDu = SingleCaseDuCase + +[] +type DuWithData = SingleCase of field:int + """ + |> compile + |> shouldSucceed + + [] let ``Struct DU compilation - have a look at IL for massive cases`` () = createMassiveStructDuProgram 15 From 1471810bfcf30ce82e5fc7847c74b87cecccbc5d Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 28 Jul 2023 11:01:20 +0200 Subject: [PATCH 07/20] Fix single case DU wrapper and marker "types" --- src/Compiler/CodeGen/EraseUnions.fs | 12 ++++++++---- .../Types/UnionTypes/UnionStructTypes.fs | 14 +++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index 700df5bc68c..eabe7fddd95 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -359,7 +359,10 @@ let convNewDataInstrInternal ilg cuspec cidx = instrs @ [ mkNormalNewobj (mkILCtorMethSpecForTy (baseTy, (ctorFieldTys @ tagfields))) ] - elif cuspecRepr.RepresentAlternativeAsStructValue cuspec then + elif + cuspecRepr.RepresentAlternativeAsStructValue cuspec + && cuspecRepr.DiscriminationTechnique cuspec = IntegerTag + then // Structs with fields should be created using maker methods (mkMakerName), only field-less cases are created this way assert (alt.IsNullary) let baseTy = baseTyOfUnionSpec cuspec @@ -891,9 +894,10 @@ let convAlternativeDef [ ldloca ILInstr.I_initobj baseTy - ldloca - mkLdcInt32 num - mkSetTagToField g.ilg cuspec baseTy + if (repr.DiscriminationTechnique info) = IntegerTag then + ldloca + mkLdcInt32 num + mkSetTagToField g.ilg cuspec baseTy for i in 0 .. fields.Length - 1 do ldloca mkLdarg (uint16 i) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs index 485aa5ac087..85764d5682f 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs @@ -671,11 +671,9 @@ let main _argv = [] - let ``Single case DU keeps working`` () = + let ``Single case DU wrapper works`` () = Fsx """ namespace Foo -[] -type TagOnlyDu = SingleCaseDuCase [] type DuWithData = SingleCase of field:int @@ -683,6 +681,16 @@ type DuWithData = SingleCase of field:int |> compile |> shouldSucceed + [] + let ``Single case DU marker works`` () = + Fsx """ +namespace Foo +[] +type TagOnlyDu = SingleCaseDuCase + """ + |> compile + |> shouldSucceed + [] let ``Struct DU compilation - have a look at IL for massive cases`` () = From 6fda6a698d8b7a0bc6b21ba426b6f53c6f119bba Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 28 Jul 2023 12:32:09 +0200 Subject: [PATCH 08/20] failing test for custom ValueOption --- src/Compiler/CodeGen/EraseUnions.fs | 2 +- .../Types/UnionTypes/UnionStructTypes.fs | 65 +++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index eabe7fddd95..d4d66503c2f 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -894,7 +894,7 @@ let convAlternativeDef [ ldloca ILInstr.I_initobj baseTy - if (repr.DiscriminationTechnique info) = IntegerTag then + if (repr.DiscriminationTechnique info) = IntegerTag && num <> 0 then ldloca mkLdcInt32 num mkSetTagToField g.ilg cuspec baseTy diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs index 85764d5682f..00f5e5fca30 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs @@ -691,6 +691,71 @@ type TagOnlyDu = SingleCaseDuCase |> compile |> shouldSucceed + [] + let ``Generic struct DU works`` () = + Fsx """ +namespace Foo +[] +type GenericStructDu<'T> = EmptyFirst | SingleVal of f:'T | DoubleVal of f2:'T * int + """ + |> compile + |> shouldSucceed + + [] + let ``Struct DU ValueOption keeps working`` () = + Fsx """ +module VOTests + +let nothing = ValueNone +let someInt = ValueSome 42 +let someSomeInt = ValueSome (ValueSome 2112) + +let matchOnVO arg = + match arg with + | ValueNone -> 333 + | ValueSome 42 -> 666 + | ValueSome anyOther -> 999 + +let result1 = matchOnVO nothing +let result2 = matchOnVO someInt + +printf $"{result1};{result2}" + + """ + |> asExe + |> compile + |> shouldSucceed + |> run + |> verifyOutput "333;666" + + [] + let ``Custom ValueOption keeps working`` () = + Fsx """ +module XX +open System + +[] +[] +type ThisIsMyValueOptionType<'T> = + | MyValueNone + | MyValueSome of Item:'T + + static member None = MyValueNone + static member Some (value) = MyValueSome(value) + + + +let x = ThisIsMyValueOptionType.Some(42) +[] +let main args = + printf "%A" x + 0 """ + |> asExe + |> compile + |> verifyIL ["abc"] + //|> shouldSucceed + //|> run + //|> verifyOutput "MyValueSome 42" [] let ``Struct DU compilation - have a look at IL for massive cases`` () = From 2d90917a4c69a102d91a705206cc8d98f28692aa Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 28 Jul 2023 14:06:44 +0200 Subject: [PATCH 09/20] adjusting .maxstack --- src/Compiler/CodeGen/EraseUnions.fs | 2 +- .../Types/UnionTypes/UnionStructTypes.fs | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index d4d66503c2f..d00c45f2df7 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -924,7 +924,7 @@ let convAlternativeDef |> Array.map (fun fd -> mkILParamNamed (fd.LowerName, fd.Type)) |> Array.toList, mkILReturn baseTy, - mkMethodBody (true, locals, fields.Length, nonBranchingInstrsToCode ilInstrs, attr, imports) + mkMethodBody (true, locals, fields.Length + locals.Length, nonBranchingInstrsToCode ilInstrs, attr, imports) ) |> addMethodGeneratedAttrs |> addAltAttribs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs index 00f5e5fca30..46ebe97f112 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs @@ -752,10 +752,17 @@ let main args = 0 """ |> asExe |> compile - |> verifyIL ["abc"] - //|> shouldSucceed - //|> run - //|> verifyOutput "MyValueSome 42" + |> shouldSucceed + |> run + |> verifyOutput "MyValueSome 42" + + [] + let sysDiagnostics = + #if NETCOREAPP + "[runtime]System.Diagnostics" + #else + "System.Diagnostics" + #endif [] let ``Struct DU compilation - have a look at IL for massive cases`` () = @@ -765,7 +772,7 @@ let main args = |> verifyIL [(*This is case-agnostic constructor used for data-less cases, just fills in the _tag property*)""" instance void .ctor(int32 _tag) cil managed { - .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + .custom instance void """+sysDiagnostics+""".CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype """+sysDiagnostics+""".CodeAnalysis.DynamicallyAccessedMemberTypes, class [runtime]System.Type) = ( 01 00 60 06 00 00 0F 46 6F 6F 2B 53 74 72 75 63 74 55 6E 69 6F 6E 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -793,7 +800,7 @@ let main args = .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 02 00 00 00 00 00 ) - .maxstack 2 + .maxstack 3 .locals init (valuetype Foo/StructUnion V_0) IL_0000: ldloca.s V_0 IL_0002: initobj Foo/StructUnion From 26994d002ba14826cc6f6f9873926d13f68ee2cd Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 28 Jul 2023 16:04:44 +0200 Subject: [PATCH 10/20] IL baselines updated --- .../Inlining/Match01.fs.il.net472.debug.bsl | 72 ++--- .../Inlining/Match01.fs.il.net472.release.bsl | 72 ++--- .../Inlining/Match01.fs.il.netcore.debug.bsl | 72 ++--- .../Match01.fs.il.netcore.release.bsl | 72 ++--- .../Inlining/StructUnion01.fs.il.net472.bsl | 131 +------- .../Inlining/StructUnion01.fs.il.netcore.bsl | 286 +++++++++--------- .../TestFunctions/Verify13043.fs.il.debug.bsl | 152 +++++----- .../Verify13043.fs.il.release.bsl | 152 +++++----- 8 files changed, 447 insertions(+), 562 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.debug.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.debug.bsl index 06514590ac1..45ba3be6216 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.debug.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.debug.bsl @@ -1125,6 +1125,42 @@ } } + .method public static int32 select1(class assembly/Test1 x) cil managed + { + + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: call instance int32 assembly/Test1::get_Tag() + IL_0007: switch ( + IL_001c, + IL_0028, + IL_002a, + IL_002c) + IL_001c: ldarg.0 + IL_001d: castclass assembly/Test1/X11 + IL_0022: ldfld int32 assembly/Test1/X11::item + IL_0027: ret + + IL_0028: ldc.i4.2 + IL_0029: ret + + IL_002a: ldc.i4.3 + IL_002b: ret + + IL_002c: ldc.i4.4 + IL_002d: ret + } + + .method public static int32 fm(class assembly/Test1 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call int32 assembly::select1(class assembly/Test1) + IL_0006: ret + } + .method assembly static int32 CompareTo$cont@4(class assembly/Test1 this, class assembly/Test1 obj, class [FSharp.Core]Microsoft.FSharp.Core.Unit unitVar) cil managed @@ -1386,42 +1422,6 @@ IL_00ef: ret } - .method public static int32 select1(class assembly/Test1 x) cil managed - { - - .maxstack 8 - IL_0000: nop - IL_0001: ldarg.0 - IL_0002: call instance int32 assembly/Test1::get_Tag() - IL_0007: switch ( - IL_001c, - IL_0028, - IL_002a, - IL_002c) - IL_001c: ldarg.0 - IL_001d: castclass assembly/Test1/X11 - IL_0022: ldfld int32 assembly/Test1/X11::item - IL_0027: ret - - IL_0028: ldc.i4.2 - IL_0029: ret - - IL_002a: ldc.i4.3 - IL_002b: ret - - IL_002c: ldc.i4.4 - IL_002d: ret - } - - .method public static int32 fm(class assembly/Test1 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call int32 assembly::select1(class assembly/Test1) - IL_0006: ret - } - } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.release.bsl index 6b5629b9317..13e4c61843e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.release.bsl @@ -1120,6 +1120,42 @@ } } + .method public static int32 select1(class assembly/Test1 x) cil managed + { + + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: call instance int32 assembly/Test1::get_Tag() + IL_0007: switch ( + IL_001c, + IL_0028, + IL_002a, + IL_002c) + IL_001c: ldarg.0 + IL_001d: castclass assembly/Test1/X11 + IL_0022: ldfld int32 assembly/Test1/X11::item + IL_0027: ret + + IL_0028: ldc.i4.2 + IL_0029: ret + + IL_002a: ldc.i4.3 + IL_002b: ret + + IL_002c: ldc.i4.4 + IL_002d: ret + } + + .method public static int32 fm(class assembly/Test1 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call int32 assembly::select1(class assembly/Test1) + IL_0006: ret + } + .method assembly static int32 CompareTo$cont@4(class assembly/Test1 this, class assembly/Test1 obj, class [FSharp.Core]Microsoft.FSharp.Core.Unit unitVar) cil managed @@ -1389,42 +1425,6 @@ IL_00fc: ret } - .method public static int32 select1(class assembly/Test1 x) cil managed - { - - .maxstack 8 - IL_0000: nop - IL_0001: ldarg.0 - IL_0002: call instance int32 assembly/Test1::get_Tag() - IL_0007: switch ( - IL_001c, - IL_0028, - IL_002a, - IL_002c) - IL_001c: ldarg.0 - IL_001d: castclass assembly/Test1/X11 - IL_0022: ldfld int32 assembly/Test1/X11::item - IL_0027: ret - - IL_0028: ldc.i4.2 - IL_0029: ret - - IL_002a: ldc.i4.3 - IL_002b: ret - - IL_002c: ldc.i4.4 - IL_002d: ret - } - - .method public static int32 fm(class assembly/Test1 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call int32 assembly::select1(class assembly/Test1) - IL_0006: ret - } - } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.debug.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.debug.bsl index a26af5e534a..9f7c89bc0ad 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.debug.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.debug.bsl @@ -1125,6 +1125,42 @@ } } + .method public static int32 select1(class assembly/Test1 x) cil managed + { + + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: call instance int32 assembly/Test1::get_Tag() + IL_0007: switch ( + IL_001c, + IL_0028, + IL_002a, + IL_002c) + IL_001c: ldarg.0 + IL_001d: castclass assembly/Test1/X11 + IL_0022: ldfld int32 assembly/Test1/X11::item + IL_0027: ret + + IL_0028: ldc.i4.2 + IL_0029: ret + + IL_002a: ldc.i4.3 + IL_002b: ret + + IL_002c: ldc.i4.4 + IL_002d: ret + } + + .method public static int32 fm(class assembly/Test1 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call int32 assembly::select1(class assembly/Test1) + IL_0006: ret + } + .method assembly static int32 CompareTo$cont@4(class assembly/Test1 this, class assembly/Test1 obj, class [FSharp.Core]Microsoft.FSharp.Core.Unit unitVar) cil managed @@ -1386,42 +1422,6 @@ IL_00ef: ret } - .method public static int32 select1(class assembly/Test1 x) cil managed - { - - .maxstack 8 - IL_0000: nop - IL_0001: ldarg.0 - IL_0002: call instance int32 assembly/Test1::get_Tag() - IL_0007: switch ( - IL_001c, - IL_0028, - IL_002a, - IL_002c) - IL_001c: ldarg.0 - IL_001d: castclass assembly/Test1/X11 - IL_0022: ldfld int32 assembly/Test1/X11::item - IL_0027: ret - - IL_0028: ldc.i4.2 - IL_0029: ret - - IL_002a: ldc.i4.3 - IL_002b: ret - - IL_002c: ldc.i4.4 - IL_002d: ret - } - - .method public static int32 fm(class assembly/Test1 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call int32 assembly::select1(class assembly/Test1) - IL_0006: ret - } - } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.release.bsl index c6444083260..986841f2ee8 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.release.bsl @@ -1120,6 +1120,42 @@ } } + .method public static int32 select1(class assembly/Test1 x) cil managed + { + + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: call instance int32 assembly/Test1::get_Tag() + IL_0007: switch ( + IL_001c, + IL_0028, + IL_002a, + IL_002c) + IL_001c: ldarg.0 + IL_001d: castclass assembly/Test1/X11 + IL_0022: ldfld int32 assembly/Test1/X11::item + IL_0027: ret + + IL_0028: ldc.i4.2 + IL_0029: ret + + IL_002a: ldc.i4.3 + IL_002b: ret + + IL_002c: ldc.i4.4 + IL_002d: ret + } + + .method public static int32 fm(class assembly/Test1 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call int32 assembly::select1(class assembly/Test1) + IL_0006: ret + } + .method assembly static int32 CompareTo$cont@4(class assembly/Test1 this, class assembly/Test1 obj, class [FSharp.Core]Microsoft.FSharp.Core.Unit unitVar) cil managed @@ -1389,42 +1425,6 @@ IL_00fc: ret } - .method public static int32 select1(class assembly/Test1 x) cil managed - { - - .maxstack 8 - IL_0000: nop - IL_0001: ldarg.0 - IL_0002: call instance int32 assembly/Test1::get_Tag() - IL_0007: switch ( - IL_001c, - IL_0028, - IL_002a, - IL_002c) - IL_001c: ldarg.0 - IL_001d: castclass assembly/Test1/X11 - IL_0022: ldfld int32 assembly/Test1/X11::item - IL_0027: ret - - IL_0028: ldc.i4.2 - IL_0029: ret - - IL_002a: ldc.i4.3 - IL_002b: ret - - IL_002c: ldc.i4.4 - IL_002d: ret - } - - .method public static int32 fm(class assembly/Test1 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call int32 assembly::select1(class assembly/Test1) - IL_0006: ret - } - } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.net472.bsl index c6d02a9df1f..6733894d53f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.net472.bsl @@ -70,32 +70,18 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: newobj instance void assembly/U::.ctor(int32, - int32) - IL_0007: ret - } - - .method assembly specialname rtspecialname - instance void .ctor(int32 item1, - int32 item2) cil managed - { - .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, - class [runtime]System.Type) = ( 01 00 60 06 00 00 0F 53 74 72 75 63 74 55 6E 69 - 6F 6E 30 31 2B 55 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/U::item1 - IL_0007: ldarg.0 - IL_0008: ldarg.2 - IL_0009: stfld int32 assembly/U::item2 - IL_000e: ret + .maxstack 3 + .locals init (valuetype assembly/U V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj assembly/U + IL_0008: ldloca.s V_0 + IL_000a: ldarg.0 + IL_000b: stfld int32 assembly/U::item1 + IL_0010: ldloca.s V_0 + IL_0012: ldarg.1 + IL_0013: stfld int32 assembly/U::item2 + IL_0018: ldloc.0 + IL_0019: ret } .method public hidebysig instance int32 @@ -723,99 +709,6 @@ } -.class private auto ansi serializable sealed System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes - extends [runtime]System.Enum -{ - .custom instance void [runtime]System.FlagsAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .field public specialname rtspecialname int32 value__ - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes All = int32(0xFFFFFFFF) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes None = int32(0x00000000) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicParameterlessConstructor = int32(0x00000001) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicConstructors = int32(0x00000003) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicConstructors = int32(0x00000004) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicMethods = int32(0x00000008) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicMethods = int32(0x00000010) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicFields = int32(0x00000020) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicFields = int32(0x00000040) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicNestedTypes = int32(0x00000080) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicNestedTypes = int32(0x00000100) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicProperties = int32(0x00000200) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicProperties = int32(0x00000400) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicEvents = int32(0x00000800) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicEvents = int32(0x00001000) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes Interfaces = int32(0x00002000) -} - -.class private auto ansi beforefieldinit System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute - extends [runtime]System.Attribute -{ - .field private valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType@ - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .field private class [runtime]System.Type Type@ - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .method public specialname rtspecialname - instance void .ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType, - class [runtime]System.Type Type) cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void [runtime]System.Attribute::.ctor() - IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ - IL_000d: ldarg.0 - IL_000e: ldarg.2 - IL_000f: stfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ - IL_0014: ret - } - - .method public hidebysig specialname instance class [runtime]System.Type - get_Type() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ - IL_0006: ret - } - - .method public hidebysig specialname instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes - get_MemberType() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ - IL_0006: ret - } - - .property instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes - MemberType() - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .get instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_MemberType() - } - .property instance class [runtime]System.Type - Type() - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .get instance class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_Type() - } -} - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.netcore.bsl index bd99fcd158f..f9e8a68c5d8 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.netcore.bsl @@ -9,31 +9,31 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - - + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + .hash algorithm 0x00008004 .ver 0:0:0:0 } .mresource public FSharpSignatureData.assembly { - - + + } .mresource public FSharpOptimizationData.assembly { - - + + } .module assembly.exe .imagebase {value} .file alignment 0x00000200 .stackreserve 0x00100000 -.subsystem 0x0003 -.corflags 0x00000001 +.subsystem 0x0003 +.corflags 0x00000001 @@ -42,7 +42,7 @@ .class public abstract auto ansi sealed assembly extends [runtime]System.Object { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) .class sequential autochar serializable sealed nested public beforefieldinit U extends [runtime]System.ValueType implements class [runtime]System.IEquatable`1, @@ -51,96 +51,82 @@ [runtime]System.IComparable, [runtime]System.Collections.IStructuralComparable { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C - 61 79 28 29 2C 6E 71 7D 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) .field assembly int32 item1 - .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .field assembly int32 item2 - .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .method public static valuetype assembly/U + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public static valuetype assembly/U NewU(int32 item1, int32 item2) cil managed { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, - int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: newobj instance void assembly/U::.ctor(int32, - int32) - IL_0007: ret - } - - .method assembly specialname rtspecialname - instance void .ctor(int32 item1, - int32 item2) cil managed - { - .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, - class [runtime]System.Type) = ( 01 00 60 06 00 00 0F 53 74 72 75 63 74 55 6E 69 - 6F 6E 30 31 2B 55 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/U::item1 - IL_0007: ldarg.0 - IL_0008: ldarg.2 - IL_0009: stfld int32 assembly/U::item2 - IL_000e: ret - } + int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/U V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj assembly/U + IL_0008: ldloca.s V_0 + IL_000a: ldarg.0 + IL_000b: stfld int32 assembly/U::item1 + IL_0010: ldloca.s V_0 + IL_0012: ldarg.1 + IL_0013: stfld int32 assembly/U::item2 + IL_0018: ldloc.0 + IL_0019: ret + } - .method public hidebysig instance int32 + .method public hidebysig instance int32 get_Item1() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: ldfld int32 assembly/U::item1 IL_0006: ret - } + } - .method public hidebysig instance int32 + .method public hidebysig instance int32 get_Item2() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: ldfld int32 assembly/U::item2 IL_0006: ret - } + } - .method public hidebysig instance int32 + .method public hidebysig instance int32 get_Tag() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: pop IL_0002: ldc.i4.0 IL_0003: ret - } + } - .method assembly hidebysig specialname + .method assembly hidebysig specialname instance object __DebugDisplay() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldstr "%+0.8A" IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,string>::.ctor(string) @@ -149,13 +135,13 @@ IL_0010: ldobj assembly/U IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) IL_001a: ret - } + } - .method public strict virtual instance string + .method public strict virtual instance string ToString() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldstr "%+A" IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,valuetype assembly/U>::.ctor(string) @@ -164,13 +150,13 @@ IL_0010: ldobj assembly/U IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) IL_001a: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 CompareTo(valuetype assembly/U obj) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 5 .locals init (int32 V_0, class [runtime]System.Collections.IComparer V_1, @@ -224,27 +210,27 @@ IL_0048: clt IL_004a: sub IL_004b: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 CompareTo(object obj) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: unbox.any assembly/U IL_0007: call instance int32 assembly/U::CompareTo(valuetype assembly/U) IL_000c: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 CompareTo(object obj, class [runtime]System.Collections.IComparer comp) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 5 .locals init (valuetype assembly/U V_0, int32 V_1, @@ -297,13 +283,13 @@ IL_0043: clt IL_0045: sub IL_0046: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 GetHashCode(class [runtime]System.Collections.IEqualityComparer comp) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 7 .locals init (int32 V_0) IL_0000: ldc.i4.0 @@ -340,26 +326,26 @@ IL_002f: stloc.0 IL_0030: ldloc.0 IL_0031: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 GetHashCode() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: call class [runtime]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer() IL_0006: call instance int32 assembly/U::GetHashCode(class [runtime]System.Collections.IEqualityComparer) IL_000b: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance bool Equals(object obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 4 .locals init (valuetype assembly/U V_0) IL_0000: ldarg.1 @@ -389,13 +375,13 @@ IL_0032: ldc.i4.0 IL_0033: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance bool Equals(valuetype assembly/U obj) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: pop @@ -414,13 +400,13 @@ IL_0021: ldc.i4.0 IL_0022: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance bool Equals(object obj) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.1 IL_0001: isinst assembly/U @@ -434,38 +420,38 @@ IL_0015: ldc.i4.0 IL_0016: ret - } + } .property instance int32 Tag() { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .get instance int32 assembly/U::get_Tag() - } + } .property instance int32 Item1() { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, - int32) = ( 01 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + int32) = ( 01 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance int32 assembly/U::get_Item1() - } + } .property instance int32 Item2() { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, - int32) = ( 01 00 04 00 00 00 00 00 00 00 01 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + int32) = ( 01 00 04 00 00 00 00 00 00 00 01 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance int32 assembly/U::get_Item2() - } - } + } + } .method public static int32 g1(valuetype assembly/U _arg1) cil managed { - + .maxstack 8 IL_0000: ldarga.s _arg1 IL_0002: ldfld int32 assembly/U::item1 @@ -473,11 +459,11 @@ IL_0009: ldfld int32 assembly/U::item2 IL_000e: add IL_000f: ret - } + } .method public static int32 g2(valuetype assembly/U u) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarga.s u @@ -486,18 +472,18 @@ IL_000a: ldfld int32 assembly/U::item2 IL_000f: add IL_0010: ret - } + } .method public static int32 g3(valuetype assembly/U x) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarga.s x IL_0003: ldfld int32 assembly/U::item1 IL_0008: ldc.i4.3 IL_0009: sub - IL_000a: switch ( + IL_000a: switch ( IL_0015) IL_0013: br.s IL_001d @@ -511,13 +497,13 @@ IL_0026: ldfld int32 assembly/U::item2 IL_002b: add IL_002c: ret - } + } .method public static int32 g4(valuetype assembly/U x, valuetype assembly/U y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .maxstack 6 .locals init (int32 V_0, int32 V_1, @@ -528,7 +514,7 @@ IL_0003: ldfld int32 assembly/U::item1 IL_0008: ldc.i4.3 IL_0009: sub - IL_000a: switch ( + IL_000a: switch ( IL_0015) IL_0013: br.s IL_0059 @@ -536,7 +522,7 @@ IL_0017: ldfld int32 assembly/U::item1 IL_001c: ldc.i4.5 IL_001d: sub - IL_001e: switch ( + IL_001e: switch ( IL_0049) IL_0027: ldarga.s y IL_0029: ldfld int32 assembly/U::item2 @@ -579,11 +565,11 @@ IL_007e: ldloc.0 IL_007f: add IL_0080: ret - } + } .method public static int32 f1(valuetype assembly/U& x) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarg.0 @@ -592,11 +578,11 @@ IL_0008: ldfld int32 assembly/U::item2 IL_000d: add IL_000e: ret - } + } .method public static int32 f2(valuetype assembly/U& x) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarg.0 @@ -605,18 +591,18 @@ IL_0008: ldfld int32 assembly/U::item2 IL_000d: add IL_000e: ret - } + } .method public static int32 f3(valuetype assembly/U& x) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarg.0 IL_0002: ldfld int32 assembly/U::item1 IL_0007: ldc.i4.3 IL_0008: sub - IL_0009: switch ( + IL_0009: switch ( IL_0014) IL_0012: br.s IL_001b @@ -630,13 +616,13 @@ IL_0022: ldfld int32 assembly/U::item2 IL_0027: add IL_0028: ret - } + } .method public static int32 f4(valuetype assembly/U& x, valuetype assembly/U& y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .maxstack 6 .locals init (valuetype assembly/U V_0, valuetype assembly/U V_1, @@ -655,7 +641,7 @@ IL_0011: ldfld int32 assembly/U::item1 IL_0016: ldc.i4.3 IL_0017: sub - IL_0018: switch ( + IL_0018: switch ( IL_0023) IL_0021: br.s IL_0069 @@ -663,7 +649,7 @@ IL_0025: ldfld int32 assembly/U::item1 IL_002a: ldc.i4.5 IL_002b: sub - IL_002c: switch ( + IL_002c: switch ( IL_0059) IL_0035: ldloca.s V_1 IL_0037: ldfld int32 assembly/U::item2 @@ -706,9 +692,9 @@ IL_0092: ldloc.2 IL_0093: add IL_0094: ret - } + } -} +} .class private abstract auto ansi sealed ''.$assembly extends [runtime]System.Object @@ -716,9 +702,15 @@ .method public static void main@() cil managed { .entrypoint - + .maxstack 8 IL_0000: ret - } + } + +} + + + + + -} diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.debug.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.debug.bsl index db118790e53..a8adc2b9f6a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.debug.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.debug.bsl @@ -43,6 +43,82 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit matchResult@38 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class assembly/matchResult@38 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance bool + Invoke(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: call bool assembly::condition(int32) + IL_0006: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void assembly/matchResult@38::.ctor() + IL_0005: stsfld class assembly/matchResult@38 assembly/matchResult@38::@_instance + IL_000a: ret + } + + } + + .class auto ansi serializable sealed nested assembly beforefieldinit functionResult@43 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class assembly/functionResult@43 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance bool + Invoke(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: call bool assembly::condition(int32) + IL_0006: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void assembly/functionResult@43::.ctor() + IL_0005: stsfld class assembly/functionResult@43 assembly/functionResult@43::@_instance + IL_000a: ret + } + + } + .class auto ansi serializable sealed nested assembly beforefieldinit f@8 extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> { @@ -177,82 +253,6 @@ } - .class auto ansi serializable sealed nested assembly beforefieldinit matchResult@38 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field static assembly initonly class assembly/matchResult@38 @_instance - .method assembly specialname rtspecialname - instance void .ctor() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ret - } - - .method public strict virtual instance bool - Invoke(int32 n) cil managed - { - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: call bool assembly::condition(int32) - IL_0006: ret - } - - .method private specialname rtspecialname static - void .cctor() cil managed - { - - .maxstack 10 - IL_0000: newobj instance void assembly/matchResult@38::.ctor() - IL_0005: stsfld class assembly/matchResult@38 assembly/matchResult@38::@_instance - IL_000a: ret - } - - } - - .class auto ansi serializable sealed nested assembly beforefieldinit functionResult@43 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field static assembly initonly class assembly/functionResult@43 @_instance - .method assembly specialname rtspecialname - instance void .ctor() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ret - } - - .method public strict virtual instance bool - Invoke(int32 n) cil managed - { - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: call bool assembly::condition(int32) - IL_0006: ret - } - - .method private specialname rtspecialname static - void .cctor() cil managed - { - - .maxstack 10 - IL_0000: newobj instance void assembly/functionResult@43::.ctor() - IL_0005: stsfld class assembly/functionResult@43 assembly/functionResult@43::@_instance - IL_000a: ret - } - - } - .method public specialname static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 get_list() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.release.bsl index db118790e53..a8adc2b9f6a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.release.bsl @@ -43,6 +43,82 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit matchResult@38 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class assembly/matchResult@38 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance bool + Invoke(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: call bool assembly::condition(int32) + IL_0006: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void assembly/matchResult@38::.ctor() + IL_0005: stsfld class assembly/matchResult@38 assembly/matchResult@38::@_instance + IL_000a: ret + } + + } + + .class auto ansi serializable sealed nested assembly beforefieldinit functionResult@43 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class assembly/functionResult@43 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance bool + Invoke(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: call bool assembly::condition(int32) + IL_0006: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void assembly/functionResult@43::.ctor() + IL_0005: stsfld class assembly/functionResult@43 assembly/functionResult@43::@_instance + IL_000a: ret + } + + } + .class auto ansi serializable sealed nested assembly beforefieldinit f@8 extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> { @@ -177,82 +253,6 @@ } - .class auto ansi serializable sealed nested assembly beforefieldinit matchResult@38 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field static assembly initonly class assembly/matchResult@38 @_instance - .method assembly specialname rtspecialname - instance void .ctor() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ret - } - - .method public strict virtual instance bool - Invoke(int32 n) cil managed - { - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: call bool assembly::condition(int32) - IL_0006: ret - } - - .method private specialname rtspecialname static - void .cctor() cil managed - { - - .maxstack 10 - IL_0000: newobj instance void assembly/matchResult@38::.ctor() - IL_0005: stsfld class assembly/matchResult@38 assembly/matchResult@38::@_instance - IL_000a: ret - } - - } - - .class auto ansi serializable sealed nested assembly beforefieldinit functionResult@43 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field static assembly initonly class assembly/functionResult@43 @_instance - .method assembly specialname rtspecialname - instance void .ctor() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ret - } - - .method public strict virtual instance bool - Invoke(int32 n) cil managed - { - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: call bool assembly::condition(int32) - IL_0006: ret - } - - .method private specialname rtspecialname static - void .cctor() cil managed - { - - .maxstack 10 - IL_0000: newobj instance void assembly/functionResult@43::.ctor() - IL_0005: stsfld class assembly/functionResult@43 assembly/functionResult@43::@_instance - IL_000a: ret - } - - } - .method public specialname static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 get_list() cil managed { From f0f01088fb06c7332fd3c7da00fe4038b12f58f9 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 28 Jul 2023 17:52:20 +0200 Subject: [PATCH 11/20] Revert "IL baselines updated" This reverts commit 26994d002ba14826cc6f6f9873926d13f68ee2cd. --- .../Inlining/Match01.fs.il.net472.debug.bsl | 72 ++--- .../Inlining/Match01.fs.il.net472.release.bsl | 72 ++--- .../Inlining/Match01.fs.il.netcore.debug.bsl | 72 ++--- .../Match01.fs.il.netcore.release.bsl | 72 ++--- .../Inlining/StructUnion01.fs.il.net472.bsl | 131 +++++++- .../Inlining/StructUnion01.fs.il.netcore.bsl | 286 +++++++++--------- .../TestFunctions/Verify13043.fs.il.debug.bsl | 152 +++++----- .../Verify13043.fs.il.release.bsl | 152 +++++----- 8 files changed, 562 insertions(+), 447 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.debug.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.debug.bsl index 45ba3be6216..06514590ac1 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.debug.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.debug.bsl @@ -1125,42 +1125,6 @@ } } - .method public static int32 select1(class assembly/Test1 x) cil managed - { - - .maxstack 8 - IL_0000: nop - IL_0001: ldarg.0 - IL_0002: call instance int32 assembly/Test1::get_Tag() - IL_0007: switch ( - IL_001c, - IL_0028, - IL_002a, - IL_002c) - IL_001c: ldarg.0 - IL_001d: castclass assembly/Test1/X11 - IL_0022: ldfld int32 assembly/Test1/X11::item - IL_0027: ret - - IL_0028: ldc.i4.2 - IL_0029: ret - - IL_002a: ldc.i4.3 - IL_002b: ret - - IL_002c: ldc.i4.4 - IL_002d: ret - } - - .method public static int32 fm(class assembly/Test1 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call int32 assembly::select1(class assembly/Test1) - IL_0006: ret - } - .method assembly static int32 CompareTo$cont@4(class assembly/Test1 this, class assembly/Test1 obj, class [FSharp.Core]Microsoft.FSharp.Core.Unit unitVar) cil managed @@ -1422,6 +1386,42 @@ IL_00ef: ret } + .method public static int32 select1(class assembly/Test1 x) cil managed + { + + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: call instance int32 assembly/Test1::get_Tag() + IL_0007: switch ( + IL_001c, + IL_0028, + IL_002a, + IL_002c) + IL_001c: ldarg.0 + IL_001d: castclass assembly/Test1/X11 + IL_0022: ldfld int32 assembly/Test1/X11::item + IL_0027: ret + + IL_0028: ldc.i4.2 + IL_0029: ret + + IL_002a: ldc.i4.3 + IL_002b: ret + + IL_002c: ldc.i4.4 + IL_002d: ret + } + + .method public static int32 fm(class assembly/Test1 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call int32 assembly::select1(class assembly/Test1) + IL_0006: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.release.bsl index 13e4c61843e..6b5629b9317 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.net472.release.bsl @@ -1120,42 +1120,6 @@ } } - .method public static int32 select1(class assembly/Test1 x) cil managed - { - - .maxstack 8 - IL_0000: nop - IL_0001: ldarg.0 - IL_0002: call instance int32 assembly/Test1::get_Tag() - IL_0007: switch ( - IL_001c, - IL_0028, - IL_002a, - IL_002c) - IL_001c: ldarg.0 - IL_001d: castclass assembly/Test1/X11 - IL_0022: ldfld int32 assembly/Test1/X11::item - IL_0027: ret - - IL_0028: ldc.i4.2 - IL_0029: ret - - IL_002a: ldc.i4.3 - IL_002b: ret - - IL_002c: ldc.i4.4 - IL_002d: ret - } - - .method public static int32 fm(class assembly/Test1 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call int32 assembly::select1(class assembly/Test1) - IL_0006: ret - } - .method assembly static int32 CompareTo$cont@4(class assembly/Test1 this, class assembly/Test1 obj, class [FSharp.Core]Microsoft.FSharp.Core.Unit unitVar) cil managed @@ -1425,6 +1389,42 @@ IL_00fc: ret } + .method public static int32 select1(class assembly/Test1 x) cil managed + { + + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: call instance int32 assembly/Test1::get_Tag() + IL_0007: switch ( + IL_001c, + IL_0028, + IL_002a, + IL_002c) + IL_001c: ldarg.0 + IL_001d: castclass assembly/Test1/X11 + IL_0022: ldfld int32 assembly/Test1/X11::item + IL_0027: ret + + IL_0028: ldc.i4.2 + IL_0029: ret + + IL_002a: ldc.i4.3 + IL_002b: ret + + IL_002c: ldc.i4.4 + IL_002d: ret + } + + .method public static int32 fm(class assembly/Test1 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call int32 assembly::select1(class assembly/Test1) + IL_0006: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.debug.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.debug.bsl index 9f7c89bc0ad..a26af5e534a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.debug.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.debug.bsl @@ -1125,42 +1125,6 @@ } } - .method public static int32 select1(class assembly/Test1 x) cil managed - { - - .maxstack 8 - IL_0000: nop - IL_0001: ldarg.0 - IL_0002: call instance int32 assembly/Test1::get_Tag() - IL_0007: switch ( - IL_001c, - IL_0028, - IL_002a, - IL_002c) - IL_001c: ldarg.0 - IL_001d: castclass assembly/Test1/X11 - IL_0022: ldfld int32 assembly/Test1/X11::item - IL_0027: ret - - IL_0028: ldc.i4.2 - IL_0029: ret - - IL_002a: ldc.i4.3 - IL_002b: ret - - IL_002c: ldc.i4.4 - IL_002d: ret - } - - .method public static int32 fm(class assembly/Test1 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call int32 assembly::select1(class assembly/Test1) - IL_0006: ret - } - .method assembly static int32 CompareTo$cont@4(class assembly/Test1 this, class assembly/Test1 obj, class [FSharp.Core]Microsoft.FSharp.Core.Unit unitVar) cil managed @@ -1422,6 +1386,42 @@ IL_00ef: ret } + .method public static int32 select1(class assembly/Test1 x) cil managed + { + + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: call instance int32 assembly/Test1::get_Tag() + IL_0007: switch ( + IL_001c, + IL_0028, + IL_002a, + IL_002c) + IL_001c: ldarg.0 + IL_001d: castclass assembly/Test1/X11 + IL_0022: ldfld int32 assembly/Test1/X11::item + IL_0027: ret + + IL_0028: ldc.i4.2 + IL_0029: ret + + IL_002a: ldc.i4.3 + IL_002b: ret + + IL_002c: ldc.i4.4 + IL_002d: ret + } + + .method public static int32 fm(class assembly/Test1 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call int32 assembly::select1(class assembly/Test1) + IL_0006: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.release.bsl index 986841f2ee8..c6444083260 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Match01.fs.il.netcore.release.bsl @@ -1120,42 +1120,6 @@ } } - .method public static int32 select1(class assembly/Test1 x) cil managed - { - - .maxstack 8 - IL_0000: nop - IL_0001: ldarg.0 - IL_0002: call instance int32 assembly/Test1::get_Tag() - IL_0007: switch ( - IL_001c, - IL_0028, - IL_002a, - IL_002c) - IL_001c: ldarg.0 - IL_001d: castclass assembly/Test1/X11 - IL_0022: ldfld int32 assembly/Test1/X11::item - IL_0027: ret - - IL_0028: ldc.i4.2 - IL_0029: ret - - IL_002a: ldc.i4.3 - IL_002b: ret - - IL_002c: ldc.i4.4 - IL_002d: ret - } - - .method public static int32 fm(class assembly/Test1 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call int32 assembly::select1(class assembly/Test1) - IL_0006: ret - } - .method assembly static int32 CompareTo$cont@4(class assembly/Test1 this, class assembly/Test1 obj, class [FSharp.Core]Microsoft.FSharp.Core.Unit unitVar) cil managed @@ -1425,6 +1389,42 @@ IL_00fc: ret } + .method public static int32 select1(class assembly/Test1 x) cil managed + { + + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: call instance int32 assembly/Test1::get_Tag() + IL_0007: switch ( + IL_001c, + IL_0028, + IL_002a, + IL_002c) + IL_001c: ldarg.0 + IL_001d: castclass assembly/Test1/X11 + IL_0022: ldfld int32 assembly/Test1/X11::item + IL_0027: ret + + IL_0028: ldc.i4.2 + IL_0029: ret + + IL_002a: ldc.i4.3 + IL_002b: ret + + IL_002c: ldc.i4.4 + IL_002d: ret + } + + .method public static int32 fm(class assembly/Test1 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call int32 assembly::select1(class assembly/Test1) + IL_0006: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.net472.bsl index 6733894d53f..c6d02a9df1f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.net472.bsl @@ -70,18 +70,32 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) - .maxstack 3 - .locals init (valuetype assembly/U V_0) - IL_0000: ldloca.s V_0 - IL_0002: initobj assembly/U - IL_0008: ldloca.s V_0 - IL_000a: ldarg.0 - IL_000b: stfld int32 assembly/U::item1 - IL_0010: ldloca.s V_0 - IL_0012: ldarg.1 - IL_0013: stfld int32 assembly/U::item2 - IL_0018: ldloc.0 - IL_0019: ret + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: newobj instance void assembly/U::.ctor(int32, + int32) + IL_0007: ret + } + + .method assembly specialname rtspecialname + instance void .ctor(int32 item1, + int32 item2) cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 0F 53 74 72 75 63 74 55 6E 69 + 6F 6E 30 31 2B 55 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/U::item1 + IL_0007: ldarg.0 + IL_0008: ldarg.2 + IL_0009: stfld int32 assembly/U::item2 + IL_000e: ret } .method public hidebysig instance int32 @@ -709,6 +723,99 @@ } +.class private auto ansi serializable sealed System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + extends [runtime]System.Enum +{ + .custom instance void [runtime]System.FlagsAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes All = int32(0xFFFFFFFF) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes None = int32(0x00000000) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicParameterlessConstructor = int32(0x00000001) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicConstructors = int32(0x00000003) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicConstructors = int32(0x00000004) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicMethods = int32(0x00000008) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicMethods = int32(0x00000010) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicFields = int32(0x00000020) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicFields = int32(0x00000040) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicNestedTypes = int32(0x00000080) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicNestedTypes = int32(0x00000100) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicProperties = int32(0x00000200) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicProperties = int32(0x00000400) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicEvents = int32(0x00000800) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicEvents = int32(0x00001000) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes Interfaces = int32(0x00002000) +} + +.class private auto ansi beforefieldinit System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute + extends [runtime]System.Attribute +{ + .field private valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field private class [runtime]System.Type Type@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType, + class [runtime]System.Type Type) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ + IL_0014: ret + } + + .method public hidebysig specialname instance class [runtime]System.Type + get_Type() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ + IL_0006: ret + } + + .method public hidebysig specialname instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + get_MemberType() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ + IL_0006: ret + } + + .property instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + MemberType() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_MemberType() + } + .property instance class [runtime]System.Type + Type() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_Type() + } +} + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.netcore.bsl index f9e8a68c5d8..bd99fcd158f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.netcore.bsl @@ -9,31 +9,31 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + - - .hash algorithm 0x00008004 .ver 0:0:0:0 } .mresource public FSharpSignatureData.assembly { - - + + } .mresource public FSharpOptimizationData.assembly { - - + + } .module assembly.exe .imagebase {value} .file alignment 0x00000200 .stackreserve 0x00100000 -.subsystem 0x0003 -.corflags 0x00000001 +.subsystem 0x0003 +.corflags 0x00000001 @@ -42,7 +42,7 @@ .class public abstract auto ansi sealed assembly extends [runtime]System.Object { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) .class sequential autochar serializable sealed nested public beforefieldinit U extends [runtime]System.ValueType implements class [runtime]System.IEquatable`1, @@ -51,82 +51,96 @@ [runtime]System.IComparable, [runtime]System.Collections.IStructuralComparable { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C - 61 79 28 29 2C 6E 71 7D 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) .field assembly int32 item1 - .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .field assembly int32 item2 - .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .method public static valuetype assembly/U + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public static valuetype assembly/U NewU(int32 item1, int32 item2) cil managed { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, - int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) - - .maxstack 3 - .locals init (valuetype assembly/U V_0) - IL_0000: ldloca.s V_0 - IL_0002: initobj assembly/U - IL_0008: ldloca.s V_0 - IL_000a: ldarg.0 - IL_000b: stfld int32 assembly/U::item1 - IL_0010: ldloca.s V_0 - IL_0012: ldarg.1 - IL_0013: stfld int32 assembly/U::item2 - IL_0018: ldloc.0 - IL_0019: ret - } + int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: newobj instance void assembly/U::.ctor(int32, + int32) + IL_0007: ret + } + + .method assembly specialname rtspecialname + instance void .ctor(int32 item1, + int32 item2) cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 0F 53 74 72 75 63 74 55 6E 69 + 6F 6E 30 31 2B 55 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/U::item1 + IL_0007: ldarg.0 + IL_0008: ldarg.2 + IL_0009: stfld int32 assembly/U::item2 + IL_000e: ret + } - .method public hidebysig instance int32 + .method public hidebysig instance int32 get_Item1() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: ldfld int32 assembly/U::item1 IL_0006: ret - } + } - .method public hidebysig instance int32 + .method public hidebysig instance int32 get_Item2() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: ldfld int32 assembly/U::item2 IL_0006: ret - } + } - .method public hidebysig instance int32 + .method public hidebysig instance int32 get_Tag() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: pop IL_0002: ldc.i4.0 IL_0003: ret - } + } - .method assembly hidebysig specialname + .method assembly hidebysig specialname instance object __DebugDisplay() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldstr "%+0.8A" IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,string>::.ctor(string) @@ -135,13 +149,13 @@ IL_0010: ldobj assembly/U IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) IL_001a: ret - } + } - .method public strict virtual instance string + .method public strict virtual instance string ToString() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldstr "%+A" IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,valuetype assembly/U>::.ctor(string) @@ -150,13 +164,13 @@ IL_0010: ldobj assembly/U IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) IL_001a: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 CompareTo(valuetype assembly/U obj) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 5 .locals init (int32 V_0, class [runtime]System.Collections.IComparer V_1, @@ -210,27 +224,27 @@ IL_0048: clt IL_004a: sub IL_004b: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 CompareTo(object obj) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: unbox.any assembly/U IL_0007: call instance int32 assembly/U::CompareTo(valuetype assembly/U) IL_000c: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 CompareTo(object obj, class [runtime]System.Collections.IComparer comp) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 5 .locals init (valuetype assembly/U V_0, int32 V_1, @@ -283,13 +297,13 @@ IL_0043: clt IL_0045: sub IL_0046: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 GetHashCode(class [runtime]System.Collections.IEqualityComparer comp) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 7 .locals init (int32 V_0) IL_0000: ldc.i4.0 @@ -326,26 +340,26 @@ IL_002f: stloc.0 IL_0030: ldloc.0 IL_0031: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 GetHashCode() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: call class [runtime]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer() IL_0006: call instance int32 assembly/U::GetHashCode(class [runtime]System.Collections.IEqualityComparer) IL_000b: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance bool Equals(object obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 4 .locals init (valuetype assembly/U V_0) IL_0000: ldarg.1 @@ -375,13 +389,13 @@ IL_0032: ldc.i4.0 IL_0033: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance bool Equals(valuetype assembly/U obj) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: pop @@ -400,13 +414,13 @@ IL_0021: ldc.i4.0 IL_0022: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance bool Equals(object obj) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.1 IL_0001: isinst assembly/U @@ -420,38 +434,38 @@ IL_0015: ldc.i4.0 IL_0016: ret - } + } .property instance int32 Tag() { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .get instance int32 assembly/U::get_Tag() - } + } .property instance int32 Item1() { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, - int32) = ( 01 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + int32) = ( 01 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance int32 assembly/U::get_Item1() - } + } .property instance int32 Item2() { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, - int32) = ( 01 00 04 00 00 00 00 00 00 00 01 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + int32) = ( 01 00 04 00 00 00 00 00 00 00 01 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance int32 assembly/U::get_Item2() - } - } + } + } .method public static int32 g1(valuetype assembly/U _arg1) cil managed { - + .maxstack 8 IL_0000: ldarga.s _arg1 IL_0002: ldfld int32 assembly/U::item1 @@ -459,11 +473,11 @@ IL_0009: ldfld int32 assembly/U::item2 IL_000e: add IL_000f: ret - } + } .method public static int32 g2(valuetype assembly/U u) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarga.s u @@ -472,18 +486,18 @@ IL_000a: ldfld int32 assembly/U::item2 IL_000f: add IL_0010: ret - } + } .method public static int32 g3(valuetype assembly/U x) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarga.s x IL_0003: ldfld int32 assembly/U::item1 IL_0008: ldc.i4.3 IL_0009: sub - IL_000a: switch ( + IL_000a: switch ( IL_0015) IL_0013: br.s IL_001d @@ -497,13 +511,13 @@ IL_0026: ldfld int32 assembly/U::item2 IL_002b: add IL_002c: ret - } + } .method public static int32 g4(valuetype assembly/U x, valuetype assembly/U y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .maxstack 6 .locals init (int32 V_0, int32 V_1, @@ -514,7 +528,7 @@ IL_0003: ldfld int32 assembly/U::item1 IL_0008: ldc.i4.3 IL_0009: sub - IL_000a: switch ( + IL_000a: switch ( IL_0015) IL_0013: br.s IL_0059 @@ -522,7 +536,7 @@ IL_0017: ldfld int32 assembly/U::item1 IL_001c: ldc.i4.5 IL_001d: sub - IL_001e: switch ( + IL_001e: switch ( IL_0049) IL_0027: ldarga.s y IL_0029: ldfld int32 assembly/U::item2 @@ -565,11 +579,11 @@ IL_007e: ldloc.0 IL_007f: add IL_0080: ret - } + } .method public static int32 f1(valuetype assembly/U& x) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarg.0 @@ -578,11 +592,11 @@ IL_0008: ldfld int32 assembly/U::item2 IL_000d: add IL_000e: ret - } + } .method public static int32 f2(valuetype assembly/U& x) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarg.0 @@ -591,18 +605,18 @@ IL_0008: ldfld int32 assembly/U::item2 IL_000d: add IL_000e: ret - } + } .method public static int32 f3(valuetype assembly/U& x) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarg.0 IL_0002: ldfld int32 assembly/U::item1 IL_0007: ldc.i4.3 IL_0008: sub - IL_0009: switch ( + IL_0009: switch ( IL_0014) IL_0012: br.s IL_001b @@ -616,13 +630,13 @@ IL_0022: ldfld int32 assembly/U::item2 IL_0027: add IL_0028: ret - } + } .method public static int32 f4(valuetype assembly/U& x, valuetype assembly/U& y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .maxstack 6 .locals init (valuetype assembly/U V_0, valuetype assembly/U V_1, @@ -641,7 +655,7 @@ IL_0011: ldfld int32 assembly/U::item1 IL_0016: ldc.i4.3 IL_0017: sub - IL_0018: switch ( + IL_0018: switch ( IL_0023) IL_0021: br.s IL_0069 @@ -649,7 +663,7 @@ IL_0025: ldfld int32 assembly/U::item1 IL_002a: ldc.i4.5 IL_002b: sub - IL_002c: switch ( + IL_002c: switch ( IL_0059) IL_0035: ldloca.s V_1 IL_0037: ldfld int32 assembly/U::item2 @@ -692,9 +706,9 @@ IL_0092: ldloc.2 IL_0093: add IL_0094: ret - } + } -} +} .class private abstract auto ansi sealed ''.$assembly extends [runtime]System.Object @@ -702,15 +716,9 @@ .method public static void main@() cil managed { .entrypoint - + .maxstack 8 IL_0000: ret - } - -} - - - - - + } +} diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.debug.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.debug.bsl index a8adc2b9f6a..db118790e53 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.debug.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.debug.bsl @@ -43,82 +43,6 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable sealed nested assembly beforefieldinit matchResult@38 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field static assembly initonly class assembly/matchResult@38 @_instance - .method assembly specialname rtspecialname - instance void .ctor() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ret - } - - .method public strict virtual instance bool - Invoke(int32 n) cil managed - { - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: call bool assembly::condition(int32) - IL_0006: ret - } - - .method private specialname rtspecialname static - void .cctor() cil managed - { - - .maxstack 10 - IL_0000: newobj instance void assembly/matchResult@38::.ctor() - IL_0005: stsfld class assembly/matchResult@38 assembly/matchResult@38::@_instance - IL_000a: ret - } - - } - - .class auto ansi serializable sealed nested assembly beforefieldinit functionResult@43 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field static assembly initonly class assembly/functionResult@43 @_instance - .method assembly specialname rtspecialname - instance void .ctor() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ret - } - - .method public strict virtual instance bool - Invoke(int32 n) cil managed - { - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: call bool assembly::condition(int32) - IL_0006: ret - } - - .method private specialname rtspecialname static - void .cctor() cil managed - { - - .maxstack 10 - IL_0000: newobj instance void assembly/functionResult@43::.ctor() - IL_0005: stsfld class assembly/functionResult@43 assembly/functionResult@43::@_instance - IL_000a: ret - } - - } - .class auto ansi serializable sealed nested assembly beforefieldinit f@8 extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> { @@ -253,6 +177,82 @@ } + .class auto ansi serializable sealed nested assembly beforefieldinit matchResult@38 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class assembly/matchResult@38 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance bool + Invoke(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: call bool assembly::condition(int32) + IL_0006: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void assembly/matchResult@38::.ctor() + IL_0005: stsfld class assembly/matchResult@38 assembly/matchResult@38::@_instance + IL_000a: ret + } + + } + + .class auto ansi serializable sealed nested assembly beforefieldinit functionResult@43 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class assembly/functionResult@43 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance bool + Invoke(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: call bool assembly::condition(int32) + IL_0006: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void assembly/functionResult@43::.ctor() + IL_0005: stsfld class assembly/functionResult@43 assembly/functionResult@43::@_instance + IL_000a: ret + } + + } + .method public specialname static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 get_list() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.release.bsl index a8adc2b9f6a..db118790e53 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.il.release.bsl @@ -43,82 +43,6 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable sealed nested assembly beforefieldinit matchResult@38 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field static assembly initonly class assembly/matchResult@38 @_instance - .method assembly specialname rtspecialname - instance void .ctor() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ret - } - - .method public strict virtual instance bool - Invoke(int32 n) cil managed - { - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: call bool assembly::condition(int32) - IL_0006: ret - } - - .method private specialname rtspecialname static - void .cctor() cil managed - { - - .maxstack 10 - IL_0000: newobj instance void assembly/matchResult@38::.ctor() - IL_0005: stsfld class assembly/matchResult@38 assembly/matchResult@38::@_instance - IL_000a: ret - } - - } - - .class auto ansi serializable sealed nested assembly beforefieldinit functionResult@43 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field static assembly initonly class assembly/functionResult@43 @_instance - .method assembly specialname rtspecialname - instance void .ctor() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ret - } - - .method public strict virtual instance bool - Invoke(int32 n) cil managed - { - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: call bool assembly::condition(int32) - IL_0006: ret - } - - .method private specialname rtspecialname static - void .cctor() cil managed - { - - .maxstack 10 - IL_0000: newobj instance void assembly/functionResult@43::.ctor() - IL_0005: stsfld class assembly/functionResult@43 assembly/functionResult@43::@_instance - IL_000a: ret - } - - } - .class auto ansi serializable sealed nested assembly beforefieldinit f@8 extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> { @@ -253,6 +177,82 @@ } + .class auto ansi serializable sealed nested assembly beforefieldinit matchResult@38 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class assembly/matchResult@38 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance bool + Invoke(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: call bool assembly::condition(int32) + IL_0006: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void assembly/matchResult@38::.ctor() + IL_0005: stsfld class assembly/matchResult@38 assembly/matchResult@38::@_instance + IL_000a: ret + } + + } + + .class auto ansi serializable sealed nested assembly beforefieldinit functionResult@43 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class assembly/functionResult@43 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance bool + Invoke(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: call bool assembly::condition(int32) + IL_0006: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void assembly/functionResult@43::.ctor() + IL_0005: stsfld class assembly/functionResult@43 assembly/functionResult@43::@_instance + IL_000a: ret + } + + } + .method public specialname static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 get_list() cil managed { From f54cbb96c9e0111e60d8a501edfbe917b25f382b Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 28 Jul 2023 18:07:26 +0200 Subject: [PATCH 12/20] now the right IL bsl updates --- .../Inlining/StructUnion01.fs.il.net472.bsl | 131 +------- .../Inlining/StructUnion01.fs.il.netcore.bsl | 286 +++++++++--------- 2 files changed, 151 insertions(+), 266 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.net472.bsl index c6d02a9df1f..6733894d53f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.net472.bsl @@ -70,32 +70,18 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: newobj instance void assembly/U::.ctor(int32, - int32) - IL_0007: ret - } - - .method assembly specialname rtspecialname - instance void .ctor(int32 item1, - int32 item2) cil managed - { - .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, - class [runtime]System.Type) = ( 01 00 60 06 00 00 0F 53 74 72 75 63 74 55 6E 69 - 6F 6E 30 31 2B 55 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/U::item1 - IL_0007: ldarg.0 - IL_0008: ldarg.2 - IL_0009: stfld int32 assembly/U::item2 - IL_000e: ret + .maxstack 3 + .locals init (valuetype assembly/U V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj assembly/U + IL_0008: ldloca.s V_0 + IL_000a: ldarg.0 + IL_000b: stfld int32 assembly/U::item1 + IL_0010: ldloca.s V_0 + IL_0012: ldarg.1 + IL_0013: stfld int32 assembly/U::item2 + IL_0018: ldloc.0 + IL_0019: ret } .method public hidebysig instance int32 @@ -723,99 +709,6 @@ } -.class private auto ansi serializable sealed System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes - extends [runtime]System.Enum -{ - .custom instance void [runtime]System.FlagsAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .field public specialname rtspecialname int32 value__ - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes All = int32(0xFFFFFFFF) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes None = int32(0x00000000) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicParameterlessConstructor = int32(0x00000001) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicConstructors = int32(0x00000003) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicConstructors = int32(0x00000004) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicMethods = int32(0x00000008) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicMethods = int32(0x00000010) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicFields = int32(0x00000020) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicFields = int32(0x00000040) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicNestedTypes = int32(0x00000080) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicNestedTypes = int32(0x00000100) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicProperties = int32(0x00000200) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicProperties = int32(0x00000400) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicEvents = int32(0x00000800) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicEvents = int32(0x00001000) - .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes Interfaces = int32(0x00002000) -} - -.class private auto ansi beforefieldinit System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute - extends [runtime]System.Attribute -{ - .field private valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType@ - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .field private class [runtime]System.Type Type@ - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .method public specialname rtspecialname - instance void .ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType, - class [runtime]System.Type Type) cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void [runtime]System.Attribute::.ctor() - IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ - IL_000d: ldarg.0 - IL_000e: ldarg.2 - IL_000f: stfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ - IL_0014: ret - } - - .method public hidebysig specialname instance class [runtime]System.Type - get_Type() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ - IL_0006: ret - } - - .method public hidebysig specialname instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes - get_MemberType() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ - IL_0006: ret - } - - .property instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes - MemberType() - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .get instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_MemberType() - } - .property instance class [runtime]System.Type - Type() - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .get instance class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_Type() - } -} - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.netcore.bsl index bd99fcd158f..f9e8a68c5d8 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/StructUnion01.fs.il.netcore.bsl @@ -9,31 +9,31 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - - + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + .hash algorithm 0x00008004 .ver 0:0:0:0 } .mresource public FSharpSignatureData.assembly { - - + + } .mresource public FSharpOptimizationData.assembly { - - + + } .module assembly.exe .imagebase {value} .file alignment 0x00000200 .stackreserve 0x00100000 -.subsystem 0x0003 -.corflags 0x00000001 +.subsystem 0x0003 +.corflags 0x00000001 @@ -42,7 +42,7 @@ .class public abstract auto ansi sealed assembly extends [runtime]System.Object { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) .class sequential autochar serializable sealed nested public beforefieldinit U extends [runtime]System.ValueType implements class [runtime]System.IEquatable`1, @@ -51,96 +51,82 @@ [runtime]System.IComparable, [runtime]System.Collections.IStructuralComparable { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C - 61 79 28 29 2C 6E 71 7D 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) .field assembly int32 item1 - .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .field assembly int32 item2 - .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .method public static valuetype assembly/U + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public static valuetype assembly/U NewU(int32 item1, int32 item2) cil managed { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, - int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: newobj instance void assembly/U::.ctor(int32, - int32) - IL_0007: ret - } - - .method assembly specialname rtspecialname - instance void .ctor(int32 item1, - int32 item2) cil managed - { - .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, - class [runtime]System.Type) = ( 01 00 60 06 00 00 0F 53 74 72 75 63 74 55 6E 69 - 6F 6E 30 31 2B 55 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/U::item1 - IL_0007: ldarg.0 - IL_0008: ldarg.2 - IL_0009: stfld int32 assembly/U::item2 - IL_000e: ret - } + int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/U V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj assembly/U + IL_0008: ldloca.s V_0 + IL_000a: ldarg.0 + IL_000b: stfld int32 assembly/U::item1 + IL_0010: ldloca.s V_0 + IL_0012: ldarg.1 + IL_0013: stfld int32 assembly/U::item2 + IL_0018: ldloc.0 + IL_0019: ret + } - .method public hidebysig instance int32 + .method public hidebysig instance int32 get_Item1() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: ldfld int32 assembly/U::item1 IL_0006: ret - } + } - .method public hidebysig instance int32 + .method public hidebysig instance int32 get_Item2() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: ldfld int32 assembly/U::item2 IL_0006: ret - } + } - .method public hidebysig instance int32 + .method public hidebysig instance int32 get_Tag() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: pop IL_0002: ldc.i4.0 IL_0003: ret - } + } - .method assembly hidebysig specialname + .method assembly hidebysig specialname instance object __DebugDisplay() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldstr "%+0.8A" IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,string>::.ctor(string) @@ -149,13 +135,13 @@ IL_0010: ldobj assembly/U IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) IL_001a: ret - } + } - .method public strict virtual instance string + .method public strict virtual instance string ToString() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldstr "%+A" IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,valuetype assembly/U>::.ctor(string) @@ -164,13 +150,13 @@ IL_0010: ldobj assembly/U IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) IL_001a: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 CompareTo(valuetype assembly/U obj) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 5 .locals init (int32 V_0, class [runtime]System.Collections.IComparer V_1, @@ -224,27 +210,27 @@ IL_0048: clt IL_004a: sub IL_004b: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 CompareTo(object obj) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: unbox.any assembly/U IL_0007: call instance int32 assembly/U::CompareTo(valuetype assembly/U) IL_000c: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 CompareTo(object obj, class [runtime]System.Collections.IComparer comp) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 5 .locals init (valuetype assembly/U V_0, int32 V_1, @@ -297,13 +283,13 @@ IL_0043: clt IL_0045: sub IL_0046: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 GetHashCode(class [runtime]System.Collections.IEqualityComparer comp) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 7 .locals init (int32 V_0) IL_0000: ldc.i4.0 @@ -340,26 +326,26 @@ IL_002f: stloc.0 IL_0030: ldloc.0 IL_0031: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance int32 GetHashCode() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: call class [runtime]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer() IL_0006: call instance int32 assembly/U::GetHashCode(class [runtime]System.Collections.IEqualityComparer) IL_000b: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance bool Equals(object obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 4 .locals init (valuetype assembly/U V_0) IL_0000: ldarg.1 @@ -389,13 +375,13 @@ IL_0032: ldc.i4.0 IL_0033: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance bool Equals(valuetype assembly/U obj) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.0 IL_0001: pop @@ -414,13 +400,13 @@ IL_0021: ldc.i4.0 IL_0022: ret - } + } - .method public hidebysig virtual final + .method public hidebysig virtual final instance bool Equals(object obj) cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .maxstack 8 IL_0000: ldarg.1 IL_0001: isinst assembly/U @@ -434,38 +420,38 @@ IL_0015: ldc.i4.0 IL_0016: ret - } + } .property instance int32 Tag() { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .get instance int32 assembly/U::get_Tag() - } + } .property instance int32 Item1() { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, - int32) = ( 01 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + int32) = ( 01 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance int32 assembly/U::get_Item1() - } + } .property instance int32 Item2() { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, - int32) = ( 01 00 04 00 00 00 00 00 00 00 01 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + int32) = ( 01 00 04 00 00 00 00 00 00 00 01 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance int32 assembly/U::get_Item2() - } - } + } + } .method public static int32 g1(valuetype assembly/U _arg1) cil managed { - + .maxstack 8 IL_0000: ldarga.s _arg1 IL_0002: ldfld int32 assembly/U::item1 @@ -473,11 +459,11 @@ IL_0009: ldfld int32 assembly/U::item2 IL_000e: add IL_000f: ret - } + } .method public static int32 g2(valuetype assembly/U u) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarga.s u @@ -486,18 +472,18 @@ IL_000a: ldfld int32 assembly/U::item2 IL_000f: add IL_0010: ret - } + } .method public static int32 g3(valuetype assembly/U x) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarga.s x IL_0003: ldfld int32 assembly/U::item1 IL_0008: ldc.i4.3 IL_0009: sub - IL_000a: switch ( + IL_000a: switch ( IL_0015) IL_0013: br.s IL_001d @@ -511,13 +497,13 @@ IL_0026: ldfld int32 assembly/U::item2 IL_002b: add IL_002c: ret - } + } .method public static int32 g4(valuetype assembly/U x, valuetype assembly/U y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .maxstack 6 .locals init (int32 V_0, int32 V_1, @@ -528,7 +514,7 @@ IL_0003: ldfld int32 assembly/U::item1 IL_0008: ldc.i4.3 IL_0009: sub - IL_000a: switch ( + IL_000a: switch ( IL_0015) IL_0013: br.s IL_0059 @@ -536,7 +522,7 @@ IL_0017: ldfld int32 assembly/U::item1 IL_001c: ldc.i4.5 IL_001d: sub - IL_001e: switch ( + IL_001e: switch ( IL_0049) IL_0027: ldarga.s y IL_0029: ldfld int32 assembly/U::item2 @@ -579,11 +565,11 @@ IL_007e: ldloc.0 IL_007f: add IL_0080: ret - } + } .method public static int32 f1(valuetype assembly/U& x) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarg.0 @@ -592,11 +578,11 @@ IL_0008: ldfld int32 assembly/U::item2 IL_000d: add IL_000e: ret - } + } .method public static int32 f2(valuetype assembly/U& x) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarg.0 @@ -605,18 +591,18 @@ IL_0008: ldfld int32 assembly/U::item2 IL_000d: add IL_000e: ret - } + } .method public static int32 f3(valuetype assembly/U& x) cil managed { - + .maxstack 8 IL_0000: nop IL_0001: ldarg.0 IL_0002: ldfld int32 assembly/U::item1 IL_0007: ldc.i4.3 IL_0008: sub - IL_0009: switch ( + IL_0009: switch ( IL_0014) IL_0012: br.s IL_001b @@ -630,13 +616,13 @@ IL_0022: ldfld int32 assembly/U::item2 IL_0027: add IL_0028: ret - } + } .method public static int32 f4(valuetype assembly/U& x, valuetype assembly/U& y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .maxstack 6 .locals init (valuetype assembly/U V_0, valuetype assembly/U V_1, @@ -655,7 +641,7 @@ IL_0011: ldfld int32 assembly/U::item1 IL_0016: ldc.i4.3 IL_0017: sub - IL_0018: switch ( + IL_0018: switch ( IL_0023) IL_0021: br.s IL_0069 @@ -663,7 +649,7 @@ IL_0025: ldfld int32 assembly/U::item1 IL_002a: ldc.i4.5 IL_002b: sub - IL_002c: switch ( + IL_002c: switch ( IL_0059) IL_0035: ldloca.s V_1 IL_0037: ldfld int32 assembly/U::item2 @@ -706,9 +692,9 @@ IL_0092: ldloc.2 IL_0093: add IL_0094: ret - } + } -} +} .class private abstract auto ansi sealed ''.$assembly extends [runtime]System.Object @@ -716,9 +702,15 @@ .method public static void main@() cil managed { .entrypoint - + .maxstack 8 IL_0000: ret - } + } + +} + + + + + -} From 641aeeb31ea8edfe696221795a7031ff102910bf Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 2 Aug 2023 17:45:22 +0200 Subject: [PATCH 13/20] struct DU - reuse fields if they have same name and type --- src/Compiler/Checking/CheckDeclarations.fs | 26 ++- src/Compiler/CodeGen/EraseUnions.fs | 11 +- src/Compiler/FSComp.txt | 2 + src/Compiler/Facilities/LanguageFeatures.fs | 3 + src/Compiler/Facilities/LanguageFeatures.fsi | 1 + 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 + .../Types/UnionTypes/UnionStructTypes.fs | 205 +++++++++++------- 19 files changed, 294 insertions(+), 84 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 63f244fc26b..8f101a3e26d 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -3349,12 +3349,26 @@ module EstablishTypeDefinitionCores = let multiCaseUnionStructCheck (unionCases: UnionCase list) = if tycon.IsStructRecordOrUnionTycon && unionCases.Length > 1 then - let fieldNames = [ for uc in unionCases do for ft in uc.FieldTable.TrueInstanceFieldsAsList do yield (ft.LogicalName, ft.Range) ] - let distFieldNames = fieldNames |> List.distinctBy fst - if distFieldNames.Length <> fieldNames.Length then - let fieldRanges = distFieldNames |> List.map snd - for m in fieldRanges do - errorR(Error(FSComp.SR.tcStructUnionMultiCaseDistinctFields(), m)) + let allTypesEqual listOfNamesAndTypes = + match listOfNamesAndTypes with + | [] | [_] -> true + | (_,headField : RecdField) :: tail -> + let headType = headField.FormalType + tail |> List.forall (fun (_,elemType) -> typeEquivAux EraseAll g elemType.FormalType headType) + + let diagnostics,duplicateCriteria = + if cenv.g.langVersion.SupportsFeature(LanguageFeature.ReuseSameFieldsInStructUnions) then + FSComp.SR.tcStructUnionMultiCaseFieldsSameType, allTypesEqual >> not + else + FSComp.SR.tcStructUnionMultiCaseDistinctFields, (fun group -> group.Length > 1) + + [ for uc in unionCases do for ft in uc.FieldTable.TrueInstanceFieldsAsList do yield(ft.LogicalName,ft) ] + |> List.groupBy fst + |> List.filter (fun (_name,group) -> duplicateCriteria group) + |> List.iter (fun (_,dups) -> + for _,ft in dups do + errorR(Error(diagnostics(), ft.Range))) + // Notify the Language Service about field names in record/class declaration let ad = envinner.AccessRights diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index d00c45f2df7..2ec97801dc9 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -1225,6 +1225,8 @@ let mkClassUnionDef |> Array.tryFindIndex (fun t -> t.IsNullary) |> Option.defaultValue -1 + let fieldsEmitted = new HashSet<_>() + for cidx, alt in Array.indexed cud.UnionCases do if repr.RepresentAlternativeAsFreshInstancesOfRootClass(info, alt) @@ -1261,6 +1263,12 @@ let mkClassUnionDef |> addMethodGeneratedAttrs ] + let fieldsToBeAddedIntoType = + alt.FieldDefs + |> Array.filter (fun f -> fieldsEmitted.Add(struct(f.LowerName,f.Type))) + + let fields = fieldsToBeAddedIntoType |> Array.map mkUnionCaseFieldId |> Array.toList + let props, meths = mkMethodsAndPropertiesForFields (addMethodGeneratedAttrs, addPropertyGeneratedAttrs) @@ -1269,13 +1277,14 @@ let mkClassUnionDef cud.DebugImports cud.HasHelpers baseTy - alt.FieldDefs + fieldsToBeAddedIntoType yield (fields, (ctor @ meths), props) ] |> List.unzip3 |> (fun (a, b, c) -> List.concat a, List.concat b, List.concat c) + let selfAndTagFields = [ for fldName, fldTy in (selfFields @ tagFieldsInObject) do diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 9f786ad9b18..3f6eedc5477 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1715,3 +1715,5 @@ featureAccessorFunctionShorthand,"underscore dot shorthand for accessor only fun 3577,tcOverrideUsesMultipleArgumentsInsteadOfTuple,"This override takes a tuple instead of multiple arguments. Try to add an additional layer of parentheses at the method definition (e.g. 'member _.Foo((x, y))'), or remove parentheses at the abstract method declaration (e.g. 'abstract member Foo: 'a * 'b -> 'c')." featureUnmanagedConstraintCsharpInterop,"Interop between C#'s and F#'s unmanaged generic constraint (emit additional modreq)" 3578,chkCopyUpdateSyntaxInAnonRecords,"This expression is an anonymous record, use {{|...|}} instead of {{...}}." +featureReuseSameFieldsInStructUnions,"Share underlying fields in a [] discriminated union as long as they have same name and type" +3579,tcStructUnionMultiCaseFieldsSameType,"If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields." diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 42aeccd5af2..8b3aba4e3c0 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -76,6 +76,7 @@ type LanguageFeature = | WarningWhenTailRecAttributeButNonTailRecUsage | UnmanagedConstraintCsharpInterop | WhileBang + | ReuseSameFieldsInStructUnions /// LanguageVersion management type LanguageVersion(versionText) = @@ -175,6 +176,7 @@ type LanguageVersion(versionText) = LanguageFeature.StrictIndentation, previewVersion LanguageFeature.UnmanagedConstraintCsharpInterop, previewVersion LanguageFeature.WhileBang, previewVersion + LanguageFeature.ReuseSameFieldsInStructUnions, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -306,6 +308,7 @@ type LanguageVersion(versionText) = | LanguageFeature.WarningWhenTailRecAttributeButNonTailRecUsage -> FSComp.SR.featureChkNotTailRecursive () | LanguageFeature.UnmanagedConstraintCsharpInterop -> FSComp.SR.featureUnmanagedConstraintCsharpInterop () | LanguageFeature.WhileBang -> FSComp.SR.featureWhileBang () + | LanguageFeature.ReuseSameFieldsInStructUnions -> FSComp.SR.featureReuseSameFieldsInStructUnions () /// 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 a3eaf39a6c7..3bb6b90548d 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -66,6 +66,7 @@ type LanguageFeature = | WarningWhenTailRecAttributeButNonTailRecUsage | UnmanagedConstraintCsharpInterop | WhileBang + | ReuseSameFieldsInStructUnions /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index eafe702269c..f19b8dd7c75 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -417,6 +417,11 @@ obnovitelné stavové stroje + + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + + self type constraints omezení vlastního typu @@ -1277,6 +1282,11 @@ Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead. + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + + This expression implicitly converts type '{0}' to type '{1}'. See https://aka.ms/fsharp-implicit-convs. Tento výraz implicitně převede typ {0} na typ {1}. Přečtěte si téma https://aka.ms/fsharp-implicit-convs. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 181d79f304d..f542a43f9c4 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -417,6 +417,11 @@ Fortsetzbarer Zustand-Maschinen + + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + + self type constraints Selbsttypeinschränkungen @@ -1277,6 +1282,11 @@ Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead. + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + + This expression implicitly converts type '{0}' to type '{1}'. See https://aka.ms/fsharp-implicit-convs. Dieser Ausdruck konvertiert den Typ "{0}" implizit in den Typ "{1}". Siehe https://aka.ms/fsharp-implicit-convs. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index b0d9d82dc97..80f7ff81071 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -417,6 +417,11 @@ máquinas de estado reanudables + + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + + self type constraints restricciones de tipo propio @@ -1277,6 +1282,11 @@ Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead. + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + + This expression implicitly converts type '{0}' to type '{1}'. See https://aka.ms/fsharp-implicit-convs. Esta expresión convierte implícitamente el tipo '{0}' al tipo '{1}'. Consulte https://aka.ms/fsharp-implicit-convs. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index e80c6033a52..64f683621b4 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -417,6 +417,11 @@ ordinateurs d’état pouvant être repris + + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + + self type constraints contraintes d’auto-type @@ -1277,6 +1282,11 @@ Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead. + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + + This expression implicitly converts type '{0}' to type '{1}'. See https://aka.ms/fsharp-implicit-convs. Cette expression convertit implicitement le type « {0} » en type « {1} ». Voir https://aka.ms/fsharp-implicit-convs. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index e40b57dae11..2ab843eeae6 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -417,6 +417,11 @@ macchine a stati ripristinabili + + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + + self type constraints vincoli di tipo automatico @@ -1277,6 +1282,11 @@ Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead. + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + + This expression implicitly converts type '{0}' to type '{1}'. See https://aka.ms/fsharp-implicit-convs. Questa espressione converte in modo implicito il tipo '{0}' nel tipo '{1}'. Vedere https://aka.ms/fsharp-implicit-convs. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 9f9830e214f..86ab7841dc6 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -417,6 +417,11 @@ 再開可能なステート マシン + + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + + self type constraints 自己型制約 @@ -1277,6 +1282,11 @@ Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead. + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + + This expression implicitly converts type '{0}' to type '{1}'. See https://aka.ms/fsharp-implicit-convs. この式は、型 '{0}' を型 '{1}' に暗黙的に変換します。https://aka.ms/fsharp-implicit-convs を参照してください。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index f5b2130327e..8c83250bc41 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -417,6 +417,11 @@ 다시 시작 가능한 상태 시스템 + + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + + self type constraints 자체 형식 제약 조건 @@ -1277,6 +1282,11 @@ Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead. + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + + This expression implicitly converts type '{0}' to type '{1}'. See https://aka.ms/fsharp-implicit-convs. 이 식은 암시적으로 '{0}' 형식을 '{1}' 형식으로 변환 합니다. https://aka.ms/fsharp-implicit-convs 참조 diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 8ba98da9f2d..51e5eb536e9 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -417,6 +417,11 @@ automaty stanów z możliwością wznowienia + + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + + self type constraints ograniczenia typu własnego @@ -1277,6 +1282,11 @@ Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead. + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + + This expression implicitly converts type '{0}' to type '{1}'. See https://aka.ms/fsharp-implicit-convs. To wyrażenie bezwzględnie konwertuje typ "{0}" na typ "{1}". Zobacz https://aka.ms/fsharp-implicit-convs. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index a9c5544273f..494199c6b82 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -417,6 +417,11 @@ máquinas de estado retomável + + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + + self type constraints restrições de auto-tipo @@ -1277,6 +1282,11 @@ Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead. + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + + This expression implicitly converts type '{0}' to type '{1}'. See https://aka.ms/fsharp-implicit-convs. Essa expressão converte implicitamente o tipo '{0}' ao tipo '{1}'. Consulte https://aka.ms/fsharp-implicit-convs. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 46e5d7ba3d9..72b3abe7381 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -417,6 +417,11 @@ возобновляемые конечные автоматы + + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + + self type constraints ограничения самостоятельного типа @@ -1277,6 +1282,11 @@ Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead. + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + + This expression implicitly converts type '{0}' to type '{1}'. See https://aka.ms/fsharp-implicit-convs. Это выражение неявно преобразует тип "{0}" в тип "{1}". См. сведения на странице https://aka.ms/fsharp-implicit-convs. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 0bf209b346b..30dbba26c21 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -417,6 +417,11 @@ sürdürülebilir durum makineleri + + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + + self type constraints kendi kendine tür kısıtlamaları @@ -1277,6 +1282,11 @@ Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead. + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + + This expression implicitly converts type '{0}' to type '{1}'. See https://aka.ms/fsharp-implicit-convs. Bu ifade '{0}' türünü örtülü olarak '{1}' türüne dönüştürür. https://aka.ms/fsharp-implicit-convs adresine bakın. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 978497120a0..e85fe18cfd7 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -417,6 +417,11 @@ 可恢复状态机 + + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + + self type constraints 自类型约束 @@ -1277,6 +1282,11 @@ Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead. + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + + This expression implicitly converts type '{0}' to type '{1}'. See https://aka.ms/fsharp-implicit-convs. 此表达式将类型“{0}”隐式转换为类型“{1}”。请参阅 https://aka.ms/fsharp-implicit-convs。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 770e440ac62..54e1bc28e41 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -417,6 +417,11 @@ 可繼續的狀態機器 + + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type + + self type constraints 自我類型限制式 @@ -1277,6 +1282,11 @@ Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead. + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + + This expression implicitly converts type '{0}' to type '{1}'. See https://aka.ms/fsharp-implicit-convs. 此運算式將類型 '{0}' 隱含轉換為類型 '{1}'。請參閱 https://aka.ms/fsharp-implicit-convs。 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs index 46ebe97f112..d61a81f8c36 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs @@ -4,6 +4,76 @@ open Xunit open FSharp.Test.Compiler module UnionStructTypes = + + [] + let ``Union struct can share fields with equal name and type`` () = + Fsx """ +module FieldSharingTest +open Microsoft.FSharp.Data.UnitSystems.SI.UnitNames +[] +type StructUnion = + | A of int64*int64*int64 + | B of int64*int64*int64 + | C of int64*int64*int64 + | D of int64*int64*int64 + | E of int64*int64*int64 + | F of int64*int64*int64 + +type MyLittleAbbreviation = int64 +type DoubleAbbrev = MyLittleAbbreviation +[] +type MyUnit + +[] +type SharingAfterErasure = + | Length of int64 + | Time of int64 + | Temperature of int64 + | Pressure of int64 + | MyLittle of MyLittleAbbreviation + | DoublyAbbreviated of DoubleAbbrev + | JustPlain of int64 + | MyUnit of int64 + +[] +type GenericStruct<'T> = + | HasOne of field1:'T + | HasTwo of field1:'T * field2:'T + | HasThree of field1:'T * field2:'T * field3:'T + +[] +type MixingFields<'T> = + | JustInt of sField:string + | JustString of intField:int + | IntAndString of sField:string * intField:int + | StringAndT of sField:string * tField:'T + | Nothing + | AllThree of sField:string * intField:int * tField:'T + +let structUnionSize = sizeof +let genericSizeForInt = sizeof> +let genericSizeForString = sizeof> +let sizeForMixingWithBool = sizeof> +let sizeForMixingWithString = sizeof> +let sizeForSharingAfterErasure = sizeof + +let equalityMustKeepWorking() = + if SharingAfterErasure.Length(15L) = SharingAfterErasure.JustPlain(15L) then + failwith "Erasure must not kill equality for UoMs!" + +do equalityMustKeepWorking() + +[] +let main _args = + printf "BasicThreeLongs=%i;GenericOfInt=%i;GenericOfString=%i;MixWithBool=%i;MixWithString=%i;Erasure=%i" structUnionSize genericSizeForInt genericSizeForString sizeForMixingWithBool sizeForMixingWithString sizeForSharingAfterErasure + 0 + """ + |> withLangVersionPreview + |> asExe + |> compile + |> shouldSucceed + |> run + |> verifyOutput "BasicThreeLongs=32;GenericOfInt=16;GenericOfString=32;MixWithBool=24;MixWithString=24;Erasure=16" [] let ``If a union type has more than one case and is a struct, field must be given unique name 1`` () = @@ -118,7 +188,7 @@ type NotATree = |> shouldSucceed [] - let ``If a union type has more than one case and is a struct, field must be given unique name 10`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 10 - v7`` () = Fsx """ namespace Foo [] @@ -127,15 +197,16 @@ type StructUnion = | B of string | C of string """ + |> withLangVersion70 |> typecheck |> shouldFail |> withDiagnostics [ - (Error 3204, Line 5, Col 12, Line 5, Col 15, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - ] - + Error 3204, Line 5, Col 12, Line 5, Col 15, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'." + Error 3204, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'." + Error 3204, Line 7, Col 12, Line 7, Col 18, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'." ] [] - let ``If a union type has more than one case and is a struct, field must be given unique name 11`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 11 - preview`` () = Fsx """ namespace Foo [] @@ -144,12 +215,9 @@ type StructUnion = | B of string | C of string """ + |> withLangVersionPreview |> typecheck - |> shouldFail - |> withDiagnostics [ - (Error 3204, Line 5, Col 12, Line 5, Col 13, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - ] + |> shouldSucceed [] let ``If a union type has more than one case and is a struct, field must be given unique name 12`` () = @@ -161,12 +229,13 @@ type StructUnion = | B of b: string | C of string """ + |> withLangVersion70 |> typecheck |> shouldFail |> withDiagnostics [ - (Error 3204, Line 5, Col 12, Line 5, Col 15, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 6, Col 12, Line 6, Col 13, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - ] + Error 3204, Line 5, Col 12, Line 5, Col 15, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'." + Error 3204, Line 7, Col 12, Line 7, Col 18, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'." ] + [] let ``If a union type has more than one case and is a struct, field must be given unique name 13`` () = @@ -195,7 +264,7 @@ type StructUnion = |> shouldSucceed [] - let ``If a union type has more than one case and is a struct, field must be given unique name 15`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 15 - v7`` () = Fsx """ namespace Foo [] @@ -203,14 +272,15 @@ type StructUnion = | A of Item: int | B of string """ + |> withLangVersion70 |> typecheck |> shouldFail |> withDiagnostics [ - (Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - ] + Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'." + Error 3204, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'." ] [] - let ``If a union type has more than one case and is a struct, field must be given unique name 16`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 16 - preview`` () = Fsx """ namespace Foo [] @@ -218,14 +288,16 @@ type StructUnion = | A of Item: int | B of Item: string """ + |> withLangVersionPreview |> typecheck |> shouldFail |> withDiagnostics [ - (Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - ] + Error 3579, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields." + Error 3579, Line 6, Col 12, Line 6, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields." + ] [] - let ``If a union type has more than one case and is a struct, field must be given unique name 17`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 17 - preview`` () = Fsx """ namespace Foo [] @@ -233,11 +305,12 @@ type StructUnion = | A of Item: int | B of item : string """ + |> withLangVersionPreview |> typecheck |> shouldSucceed [] - let ``If a union type has more than one case and is a struct, field must be given unique name 18`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 18 - v7`` () = Fsx """ namespace Foo [] @@ -245,14 +318,16 @@ type StructUnion = | A of item: int | B of item: string """ + |> withLangVersion70 |> typecheck |> shouldFail |> withDiagnostics [ - (Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") + Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'." + Error 3204, Line 6, Col 12, Line 6, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'." ] [] - let ``If a union type has more than one case and is a struct, field must be given unique name 19`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 19 - v7`` () = Fsx """ namespace Foo [] @@ -260,15 +335,16 @@ type StructUnion = | A of Item: int * string | B of string """ + |> withLangVersion70 |> typecheck |> shouldFail |> withDiagnostics [ (Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 5, Col 24, Line 5, Col 30, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") + (Error 3204, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") ] [] - let ``If a union type has more than one case and is a struct, field must be given unique name 20`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 20 - preview`` () = Fsx """ namespace Foo [] @@ -276,15 +352,15 @@ type StructUnion = | A of Item: int * item: string | B of string """ + |> withLangVersionPreview |> typecheck |> shouldFail - |> withDiagnostics [ - (Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 5, Col 24, Line 5, Col 28, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - ] + |> withDiagnostics [ + Error 3579, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields." + Error 3579, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields."] [] - let ``If a union type has more than one case and is a struct, field must be given unique name 21`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 21 - preview`` () = Fsx """ namespace Foo [] @@ -292,12 +368,9 @@ type StructUnion = | A of Item: int * item: string | B of item: string """ + |> withLangVersionPreview |> typecheck - |> shouldFail - |> withDiagnostics [ - (Error 3204, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 5, Col 24, Line 5, Col 28, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - ] + |> shouldSucceed [] let ``If a union type has more than one case and is a struct, field must be given unique name 22`` () = @@ -448,17 +521,18 @@ type StructUnion = |> shouldSucceed [] - let ``If a union type has more than one case and is a struct, field must be given unique name 34`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 34 - preview`` () = Fsx """ namespace Foo [] type StructUnion = A of int | B of string """ + |> withLangVersionPreview |> typecheck |> shouldFail |> withDiagnostics [ - (Error 3204, Line 4, Col 25, Line 4, Col 28, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - ] + Error 3579, Line 4, Col 25, Line 4, Col 28, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields." + Error 3579, Line 4, Col 36, Line 4, Col 42, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields." ] [] let ``If a union type has more than one case and is a struct, field must be given unique name 35`` () = @@ -473,7 +547,7 @@ type StructUnion = |> shouldSucceed [] - let ``If a union type has more than one case and is a struct, field must be given unique name 36`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 36 - preview`` () = Fsx """ namespace Foo [] @@ -482,16 +556,12 @@ type StructUnion = | B of string | C of string """ + |> withLangVersionPreview |> typecheck - |> shouldFail - |> withDiagnostics [ - (Error 3204, Line 5, Col 12, Line 5, Col 15, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 5, Col 18, Line 5, Col 24, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - ] + |> shouldSucceed [] - let ``If a union type has more than one case and is a struct, field must be given unique name 37`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 37 - preview`` () = Fsx """ namespace Foo [] @@ -500,16 +570,12 @@ type StructUnion = | B of string | C of string """ + |> withLangVersionPreview |> typecheck - |> shouldFail - |> withDiagnostics [ - (Error 3204, Line 5, Col 12, Line 5, Col 13, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 5, Col 21, Line 5, Col 27, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - ] + |> shouldSucceed [] - let ``If a union type has more than one case and is a struct, field must be given unique name 38`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 38 - preview`` () = Fsx """ namespace Foo [] @@ -518,16 +584,12 @@ type StructUnion = | B of string | C of string """ + |> withLangVersionPreview |> typecheck - |> shouldFail - |> withDiagnostics [ - (Error 3204, Line 5, Col 12, Line 5, Col 15, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 5, Col 18, Line 5, Col 19, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - ] + |> shouldSucceed [] - let ``If a union type has more than one case and is a struct, field must be given unique name 39`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 39 - preview`` () = Fsx """ namespace Foo [] @@ -536,13 +598,9 @@ type StructUnion = | B of string | C of string """ + |> withLangVersionPreview |> typecheck - |> shouldFail - |> withDiagnostics [ - (Error 3204, Line 5, Col 12, Line 5, Col 13, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 5, Col 21, Line 5, Col 23, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - ] + |> shouldSucceed [] let ``If a union type has more than one case and is a struct, field must be given unique name 40`` () = @@ -584,7 +642,7 @@ type StructUnion = |> shouldSucceed [] - let ``If a union type has more than one case and is a struct, field must be given unique name 43`` () = + let ``If a union type has more than one case and is a struct, field must be given unique name 43 - preview`` () = Fsx """ namespace Foo [] @@ -593,16 +651,9 @@ type StructUnion = | B of string * b: string | C of c: string * string * c3: int """ - |> typecheck - |> shouldFail - |> withDiagnostics [ - (Error 3204, Line 5, Col 12, Line 5, Col 13, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 5, Col 21, Line 5, Col 27, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 6, Col 21, Line 6, Col 22, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 7, Col 12, Line 7, Col 13, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - (Error 3204, Line 7, Col 33, Line 7, Col 35, "If a multicase union type is a struct, then all union cases must have unique names. For example: 'type A = B of b: int | C of c: int'.") - ] + |> withLangVersionPreview + |> typecheck + |> shouldSucceed [] let ``If a union type has more than one case and is a struct, field must be given unique name 44`` () = From 2eb8f227e6db4820c4d50e217206a5c5f9e0b7f1 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 2 Aug 2023 17:51:33 +0200 Subject: [PATCH 14/20] formatting --- src/Compiler/CodeGen/EraseUnions.fs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index 2ec97801dc9..19eb15eba5d 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -1265,7 +1265,7 @@ let mkClassUnionDef let fieldsToBeAddedIntoType = alt.FieldDefs - |> Array.filter (fun f -> fieldsEmitted.Add(struct(f.LowerName,f.Type))) + |> Array.filter (fun f -> fieldsEmitted.Add(struct (f.LowerName, f.Type))) let fields = fieldsToBeAddedIntoType |> Array.map mkUnionCaseFieldId |> Array.toList @@ -1284,7 +1284,6 @@ let mkClassUnionDef |> List.unzip3 |> (fun (a, b, c) -> List.concat a, List.concat b, List.concat c) - let selfAndTagFields = [ for fldName, fldTy in (selfFields @ tagFieldsInObject) do From 299e0eb7e9d71906de6c6c1d9c009c5bd5eb199c Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 27 Nov 2023 17:10:08 +0100 Subject: [PATCH 15/20] Update src/Compiler/FSComp.txt Co-authored-by: Petr --- src/Compiler/FSComp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 3f6eedc5477..35c18505dbc 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1716,4 +1716,4 @@ featureAccessorFunctionShorthand,"underscore dot shorthand for accessor only fun featureUnmanagedConstraintCsharpInterop,"Interop between C#'s and F#'s unmanaged generic constraint (emit additional modreq)" 3578,chkCopyUpdateSyntaxInAnonRecords,"This expression is an anonymous record, use {{|...|}} instead of {{...}}." featureReuseSameFieldsInStructUnions,"Share underlying fields in a [] discriminated union as long as they have same name and type" -3579,tcStructUnionMultiCaseFieldsSameType,"If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields." +3579,tcStructUnionMultiCaseFieldsSameType,"If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." From 8d1560863b863297a440ff30ae8b0a889e77a1ad Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 27 Nov 2023 16:39:22 +0000 Subject: [PATCH 16/20] Automated command ran: fantomas Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com> --- src/Compiler/Facilities/LanguageFeatures.fs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index e4d446ec71b..47c99af3ba7 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -188,7 +188,7 @@ type LanguageVersion(versionText) = // F# preview LanguageFeature.FromEndSlicing, previewVersion - LanguageFeature.UnmanagedConstraintCsharpInterop, previewVersion + LanguageFeature.UnmanagedConstraintCsharpInterop, previewVersion LanguageFeature.ReuseSameFieldsInStructUnions, previewVersion LanguageFeature.PreferExtensionMethodOverPlainProperty, previewVersion LanguageFeature.WarningIndexedPropertiesGetSetSameType, previewVersion @@ -334,7 +334,6 @@ type LanguageVersion(versionText) = | LanguageFeature.WarningIndexedPropertiesGetSetSameType -> FSComp.SR.featureWarningIndexedPropertiesGetSetSameType () | LanguageFeature.WarningWhenTailCallAttrOnNonRec -> FSComp.SR.featureChkTailCallAttrOnNonRec () - /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = match features.TryGetValue feature with From c9905708213e5600619db02181dc5f37abb878da Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 27 Nov 2023 17:46:10 +0100 Subject: [PATCH 17/20] fix --- src/Compiler/FSComp.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 4d8fa546169..d7e08c6e30b 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1735,6 +1735,4 @@ featureReuseSameFieldsInStructUnions,"Share underlying fields in a [] di 3855,tcNoStaticMemberFoundForOverride,"No static abstract member was found that corresponds to this override" 3859,tcNoStaticPropertyFoundForOverride,"No static abstract property was found that corresponds to this override" 3860,chkStaticMembersOnObjectExpressions,"Object expressions cannot implement interfaces with static abstract members or declare static members." -3861,chkTailCallAttrOnNonRec,"The TailCall attribute should only be applied to recursive functions." - - +3861,chkTailCallAttrOnNonRec,"The TailCall attribute should only be applied to recursive functions." \ No newline at end of file From a231d18961024d069f0c40d279f89af2e41d7cef Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 27 Nov 2023 18:07:06 +0100 Subject: [PATCH 18/20] xlf files updated --- 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 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index ac336222525..67dc8a33de9 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -1383,8 +1383,8 @@ - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 9be8a2b4401..1ccf02ec1ee 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -1383,8 +1383,8 @@ - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index fffc095cf37..1efa1037c2c 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -1383,8 +1383,8 @@ - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index bea1bee3ee4..1e3087c77e8 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -1383,8 +1383,8 @@ - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 133ad882d53..57e483a458c 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -1383,8 +1383,8 @@ - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index ae2753f91b8..9b46ccfafcd 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -1383,8 +1383,8 @@ - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 6989663525a..f7cc2fe380c 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -1383,8 +1383,8 @@ - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 3527eb853ec..3980968d91c 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -1383,8 +1383,8 @@ - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 15bbe21896a..130775c7141 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -1383,8 +1383,8 @@ - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 8a37be37370..fb6430843c0 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -1383,8 +1383,8 @@ - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 90a3bfc25ce..637a9005ed4 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -1383,8 +1383,8 @@ - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index d7ac87984c8..f4214111d30 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -1383,8 +1383,8 @@ - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index f35b99f4dc6..e104b27d5d4 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -1383,8 +1383,8 @@ - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. - If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. From f031c507046572de4728ec68abbfc901ec3bf29c Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 28 Nov 2023 11:58:21 +0100 Subject: [PATCH 19/20] fix tests --- .../Conformance/Types/UnionTypes/UnionStructTypes.fs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs index 05d8374f07c..0a2b6c9c87f 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs @@ -292,8 +292,8 @@ type StructUnion = |> typecheck |> shouldFail |> withDiagnostics [ - Error 3579, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields." - Error 3579, Line 6, Col 12, Line 6, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields." + Error 3579, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." + Error 3579, Line 6, Col 12, Line 6, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." ] [] @@ -356,8 +356,8 @@ type StructUnion = |> typecheck |> shouldFail |> withDiagnostics [ - Error 3579, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields." - Error 3579, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields."] + Error 3579, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." + Error 3579, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields."] [] let ``If a union type has more than one case and is a struct, field must be given unique name 21 - preview`` () = @@ -531,8 +531,8 @@ type StructUnion = A of int | B of string |> typecheck |> shouldFail |> withDiagnostics [ - Error 3579, Line 4, Col 25, Line 4, Col 28, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields." - Error 3579, Line 4, Col 36, Line 4, Col 42, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rules applies also to the generated 'Item' name in case of unnamed fields." ] + Error 3579, Line 4, Col 25, Line 4, Col 28, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." + Error 3579, Line 4, Col 36, Line 4, Col 42, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." ] [] let ``If a union type has more than one case and is a struct, field must be given unique name 35`` () = From 476f1dd476f11124a016211e83b7cc6243f39d18 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 28 Nov 2023 12:01:07 +0100 Subject: [PATCH 20/20] change error code --- .../Conformance/Types/UnionTypes/UnionStructTypes.fs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs index 0a2b6c9c87f..630d2c2a838 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/UnionTypes/UnionStructTypes.fs @@ -292,8 +292,8 @@ type StructUnion = |> typecheck |> shouldFail |> withDiagnostics [ - Error 3579, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." - Error 3579, Line 6, Col 12, Line 6, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." + Error 3585, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." + Error 3585, Line 6, Col 12, Line 6, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." ] [] @@ -356,8 +356,8 @@ type StructUnion = |> typecheck |> shouldFail |> withDiagnostics [ - Error 3579, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." - Error 3579, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields."] + Error 3585, Line 5, Col 12, Line 5, Col 16, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." + Error 3585, Line 6, Col 12, Line 6, Col 18, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields."] [] let ``If a union type has more than one case and is a struct, field must be given unique name 21 - preview`` () = @@ -531,8 +531,8 @@ type StructUnion = A of int | B of string |> typecheck |> shouldFail |> withDiagnostics [ - Error 3579, Line 4, Col 25, Line 4, Col 28, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." - Error 3579, Line 4, Col 36, Line 4, Col 42, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." ] + Error 3585, Line 4, Col 25, Line 4, Col 28, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." + Error 3585, Line 4, Col 36, Line 4, Col 42, "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." ] [] let ``If a union type has more than one case and is a struct, field must be given unique name 35`` () =