From 812bf3dc3a6c17dae01976629733d9c467852849 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 22 Dec 2022 20:49:12 +0100 Subject: [PATCH] Fix a broken debug assertion that kicked in whenever building Fsharp.Core (#14435) * Fix a broken debug assertion that kicked in whenever building Fsharp.Core in Debug * HasMethodImplNoInliningAttribute unification --- src/Compiler/Checking/CheckExpressions.fs | 64 ++++++++++--------- src/Compiler/FSComp.txt | 1 + src/Compiler/Facilities/LanguageFeatures.fs | 7 +- src/Compiler/Facilities/LanguageFeatures.fsi | 1 + src/Compiler/xlf/FSComp.txt.cs.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.de.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.es.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.fr.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.it.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.ja.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.ko.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.pl.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.ru.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.tr.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 ++ ...dImplAttribute.NoInlining_InlineKeyword.fs | 3 + .../MethodImplAttribute.fs | 14 ++++ tests/FSharp.Test.Utilities/Compiler.fs | 3 + 20 files changed, 125 insertions(+), 33 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/MethodImplAttribute/MethodImplAttribute.NoInlining_InlineKeyword.fs diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index fce1f662d..ef4930408 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -1210,6 +1210,12 @@ let CheckRequiredProperties (g:TcGlobals) (env: TcEnv) (cenv: TcFileState) (minf let details = NicePrint.multiLineStringOfPropInfos g cenv.amap mMethExpr env.DisplayEnv missingProps errorR(Error(FSComp.SR.tcMissingRequiredMembers details, mMethExpr)) +let private HasMethodImplNoInliningAttribute g attrs = + match TryFindFSharpAttribute g g.attrib_MethodImplAttribute attrs with + // NO_INLINING = 8 + | Some (Attrib(_, _, [ AttribInt32Arg flags ], _, _, _, _)) -> (flags &&& 0x8) <> 0x0 + | _ -> false + let MakeAndPublishVal (cenv: cenv) env (altActualParent, inSig, declKind, valRecInfo, vscheme, attrs, xmlDoc, konst, isGeneratedEventVal) = let g = cenv.g @@ -1258,16 +1264,10 @@ let MakeAndPublishVal (cenv: cenv) env (altActualParent, inSig, declKind, valRec errorR(Error(FSComp.SR.tcDllImportStubsCannotBeInlined(), m)) ValInline.Never else - let implflags = - match TryFindFSharpAttribute g g.attrib_MethodImplAttribute attrs with - | Some (Attrib(_, _, [ AttribInt32Arg flags ], _, _, _, _)) -> flags - | _ -> 0x0 - // MethodImplOptions.NoInlining = 0x8 - let NO_INLINING = 0x8 - if (implflags &&& NO_INLINING) <> 0x0 then - ValInline.Never - else - inlineFlag + if HasMethodImplNoInliningAttribute g attrs + then ValInline.Never + else inlineFlag + // CompiledName not allowed on virtual/abstract/override members let compiledNameAttrib = TryFindFSharpStringAttribute g g.attrib_CompiledNameAttribute attrs @@ -2205,26 +2205,32 @@ module GeneralizationHelpers = // ComputeInlineFlag //------------------------------------------------------------------------- -let ComputeInlineFlag (memFlagsOption: SynMemberFlags option) isInline isMutable hasNoCompilerInliningAttribute m = - let inlineFlag = - let isCtorOrAbstractSlot = - match memFlagsOption with - | None -> false - | Some x -> (x.MemberKind = SynMemberKind.Constructor) || x.IsDispatchSlot || x.IsOverrideOrExplicitImpl +let ComputeInlineFlag (memFlagsOption: SynMemberFlags option) isInline isMutable g attrs m = + let hasNoCompilerInliningAttribute() = HasFSharpAttribute g g.attrib_NoCompilerInliningAttribute attrs + let isCtorOrAbstractSlot() = + match memFlagsOption with + | None -> false + | Some x -> (x.MemberKind = SynMemberKind.Constructor) || x.IsDispatchSlot || x.IsOverrideOrExplicitImpl + let inlineFlag, reportIncorrectInlineKeywordUsage = // Mutable values may never be inlined // Constructors may never be inlined // Calls to virtual/abstract slots may never be inlined - // Values marked with NoCompilerInliningAttribute may never be inlined - if isMutable || isCtorOrAbstractSlot || hasNoCompilerInliningAttribute then - ValInline.Never + // Values marked with NoCompilerInliningAttribute or [] may never be inlined + if isMutable || isCtorOrAbstractSlot() || hasNoCompilerInliningAttribute() then + ValInline.Never, errorR + elif HasMethodImplNoInliningAttribute g attrs then + ValInline.Never, + if g.langVersion.SupportsFeature LanguageFeature.WarningWhenInliningMethodImplNoInlineMarkedFunction + then warning + else ignore elif isInline then - ValInline.Always + ValInline.Always, ignore else - ValInline.Optional + ValInline.Optional, ignore if isInline && (inlineFlag <> ValInline.Always) then - errorR(Error(FSComp.SR.tcThisValueMayNotBeInlined(), m)) + reportIncorrectInlineKeywordUsage (Error(FSComp.SR.tcThisValueMayNotBeInlined(), m)) inlineFlag @@ -10278,10 +10284,8 @@ and TcNormalizedBinding declKind (cenv: cenv) env tpenv overallTy safeThisValOpt SynValData(valMf, SynValInfo(args, SynArgInfo({Attributes=rotRetSynAttrs; Range=mHead} :: attrs, opt, retId)), valId) retAttribs, valAttribs, valSynData - let isVolatile = HasFSharpAttribute g g.attrib_VolatileFieldAttribute valAttribs - let hasNoCompilerInliningAttribute = HasFSharpAttribute g g.attrib_NoCompilerInliningAttribute valAttribs - - let inlineFlag = ComputeInlineFlag memberFlagsOpt isInline isMutable hasNoCompilerInliningAttribute mBinding + let isVolatile = HasFSharpAttribute g g.attrib_VolatileFieldAttribute valAttribs + let inlineFlag = ComputeInlineFlag memberFlagsOpt isInline isMutable g valAttribs mBinding let argAttribs = spatsL |> List.map (SynInfo.InferSynArgInfoFromSimplePats >> List.map (SynInfo.AttribsOfArgData >> TcAttrs AttributeTargets.Parameter false)) @@ -11414,10 +11418,9 @@ and AnalyzeAndMakeAndPublishRecursiveValue let bindingAttribs = TcAttributes cenv env attrTgt bindingSynAttribs // Allocate the type inference variable for the inferred type - let ty = NewInferenceType g - let hasNoCompilerInliningAttribute = HasFSharpAttribute g g.attrib_NoCompilerInliningAttribute bindingAttribs + let ty = NewInferenceType g - let inlineFlag = ComputeInlineFlag memberFlagsOpt isInline isMutable hasNoCompilerInliningAttribute mBinding + let inlineFlag = ComputeInlineFlag memberFlagsOpt isInline isMutable g bindingAttribs mBinding if isMutable then errorR(Error(FSComp.SR.tcOnlyRecordFieldsAndSimpleLetCanBeMutable(), mBinding)) @@ -12033,7 +12036,6 @@ let TcAndPublishValSpec (cenv: cenv, env, containerInfo: ContainerInfo, declKind let attrs = TcAttributes cenv env attrTgt synAttrs let newOk = if canInferTypars then NewTyparsOK else NoNewTypars - let hasNoCompilerInliningAttribute = HasFSharpAttribute g g.attrib_NoCompilerInliningAttribute attrs let valinfos, tpenv = TcValSpec cenv env declKind newOk containerInfo memFlagsOpt None tpenv synValSig attrs let denv = env.DisplayEnv @@ -12042,7 +12044,7 @@ let TcAndPublishValSpec (cenv: cenv, env, containerInfo: ContainerInfo, declKind let (ValSpecResult (altActualParent, memberInfoOpt, id, enclosingDeclaredTypars, declaredTypars, ty, prelimValReprInfo, declKind)) = valSpecResult - let inlineFlag = ComputeInlineFlag (memberInfoOpt |> Option.map (fun (PrelimMemberInfo(memberInfo, _, _)) -> memberInfo.MemberFlags)) isInline mutableFlag hasNoCompilerInliningAttribute m + let inlineFlag = ComputeInlineFlag (memberInfoOpt |> Option.map (fun (PrelimMemberInfo(memberInfo, _, _)) -> memberInfo.MemberFlags)) isInline mutableFlag g attrs m let freeInType = freeInTypeLeftToRight g false ty diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index cb6bc023f..82659f91d 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1558,6 +1558,7 @@ featureLowercaseDUWhenRequireQualifiedAccess,"Allow lowercase DU when RequireQua featureMatchNotAllowedForUnionCaseWithNoData,"Pattern match discard is not allowed for union case that takes no data." featureCSharpExtensionAttributeNotRequired,"Allow implicit Extension attribute on declaring types, modules" featureErrorForNonVirtualMembersOverrides,"Raises errors for non-virtual members overrides" +featureWarningWhenInliningMethodImplNoInlineMarkedFunction,"Raises warnings when 'let inline ... =' is used together with [] attribute. Function is not getting inlined." featureArithmeticInLiterals,"Allow arithmetic and logical operations in literals" 3353,fsiInvalidDirective,"Invalid directive '#%s %s'" 3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index e5e842796..7dfedf0be 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -57,6 +57,7 @@ type LanguageFeature = | MatchNotAllowedForUnionCaseWithNoData | CSharpExtensionAttributeNotRequired | ErrorForNonVirtualMembersOverrides + | WarningWhenInliningMethodImplNoInlineMarkedFunction | EscapeDotnetFormattableStrings | ArithmeticInLiterals @@ -132,6 +133,7 @@ type LanguageVersion(versionText) = LanguageFeature.MatchNotAllowedForUnionCaseWithNoData, previewVersion LanguageFeature.CSharpExtensionAttributeNotRequired, previewVersion LanguageFeature.ErrorForNonVirtualMembersOverrides, previewVersion + LanguageFeature.WarningWhenInliningMethodImplNoInlineMarkedFunction, previewVersion LanguageFeature.EscapeDotnetFormattableStrings, previewVersion LanguageFeature.ArithmeticInLiterals, previewVersion @@ -242,8 +244,9 @@ type LanguageVersion(versionText) = | LanguageFeature.InterfacesWithAbstractStaticMembers -> FSComp.SR.featureInterfacesWithAbstractStaticMembers () | LanguageFeature.SelfTypeConstraints -> FSComp.SR.featureSelfTypeConstraints () | LanguageFeature.MatchNotAllowedForUnionCaseWithNoData -> FSComp.SR.featureMatchNotAllowedForUnionCaseWithNoData () - | LanguageFeature.CSharpExtensionAttributeNotRequired -> FSComp.SR.featureCSharpExtensionAttributeNotRequired () - | LanguageFeature.ErrorForNonVirtualMembersOverrides -> FSComp.SR.featureErrorForNonVirtualMembersOverrides () + | LanguageFeature.CSharpExtensionAttributeNotRequired -> FSComp.SR.featureCSharpExtensionAttributeNotRequired () + | LanguageFeature.ErrorForNonVirtualMembersOverrides -> FSComp.SR.featureErrorForNonVirtualMembersOverrides () + | LanguageFeature.WarningWhenInliningMethodImplNoInlineMarkedFunction -> FSComp.SR.featureWarningWhenInliningMethodImplNoInlineMarkedFunction () | LanguageFeature.EscapeDotnetFormattableStrings -> FSComp.SR.featureEscapeBracesInFormattableString () | LanguageFeature.ArithmeticInLiterals -> FSComp.SR.featureArithmeticInLiterals () diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index a70ec96cc..ac1ae3545 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -47,6 +47,7 @@ type LanguageFeature = | MatchNotAllowedForUnionCaseWithNoData | CSharpExtensionAttributeNotRequired | ErrorForNonVirtualMembersOverrides + | WarningWhenInliningMethodImplNoInlineMarkedFunction | EscapeDotnetFormattableStrings | ArithmeticInLiterals diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index a03a936bf..3d4773937 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -337,6 +337,11 @@ reprezentace struktury aktivních vzorů + + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + + wild card in for loop zástupný znak ve smyčce for diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 88d360b25..ee9e31430 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -337,6 +337,11 @@ Strukturdarstellung für aktive Muster + + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + + wild card in for loop Platzhalter in for-Schleife diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 02122ba62..8a61a3453 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -337,6 +337,11 @@ representación de struct para modelos activos + + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + + wild card in for loop carácter comodín en bucle for diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 483f8b91b..00a9cde1c 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -337,6 +337,11 @@ représentation de structure pour les modèles actifs + + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + + wild card in for loop caractère générique dans une boucle for diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 49cf9bad9..72ad89e88 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -337,6 +337,11 @@ rappresentazione struct per criteri attivi + + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + + wild card in for loop carattere jolly nel ciclo for diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 0ed505a87..0b0868abe 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -337,6 +337,11 @@ アクティブなパターンの構造体表現 + + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + + wild card in for loop for ループのワイルド カード diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 666a62143..fca2e1357 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -337,6 +337,11 @@ 활성 패턴에 대한 구조체 표현 + + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + + wild card in for loop for 루프의 와일드카드 diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 35f555a08..39b430d24 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -337,6 +337,11 @@ reprezentacja struktury aktywnych wzorców + + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + + wild card in for loop symbol wieloznaczny w pętli for diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 7e4a20be7..26960045d 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -337,6 +337,11 @@ representação estrutural para padrões ativos + + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + + wild card in for loop curinga para loop diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 4ab2847a1..6ce6165a5 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -337,6 +337,11 @@ представление структуры для активных шаблонов + + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + + wild card in for loop подстановочный знак в цикле for diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 85cca2042..5b53bdd6a 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -337,6 +337,11 @@ etkin desenler için yapı gösterimi + + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + + wild card in for loop for döngüsünde joker karakter diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 55f8ac8d9..7ee6ac2bd 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -337,6 +337,11 @@ 活动模式的结构表示形式 + + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + + wild card in for loop for 循环中的通配符 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 02122cbd5..46eae1565 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -337,6 +337,11 @@ 現用模式的結構表示法 + + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. + + wild card in for loop for 迴圈中的萬用字元 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/MethodImplAttribute/MethodImplAttribute.NoInlining_InlineKeyword.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/MethodImplAttribute/MethodImplAttribute.NoInlining_InlineKeyword.fs new file mode 100644 index 000000000..b40e3a3f8 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/MethodImplAttribute/MethodImplAttribute.NoInlining_InlineKeyword.fs @@ -0,0 +1,3 @@ +module M +[] +let inline getUnit (f : unit -> unit) = f() \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/MethodImplAttribute/MethodImplAttribute.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/MethodImplAttribute/MethodImplAttribute.fs index 51f758b7f..183be7e87 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/MethodImplAttribute/MethodImplAttribute.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/MethodImplAttribute/MethodImplAttribute.fs @@ -33,6 +33,20 @@ module MethodImplAttribute = let ``NoInlining_fs`` compilation = compilation |> verifyCompilation + + [] + let ``NoInlining_fs with inline keyword => should warn in preview version`` compilation = + compilation + |> withLangVersionPreview + |> typecheck + |> withSingleDiagnostic (Warning 3151, Line 2, Col 1, Line 3, Col 38, "This member, function or value declaration may not be declared 'inline'") + + [] + let ``NoInlining_fs with inline keyword => should not warn in F# 7 or older`` compilation = + compilation + |> withLangVersion70 + |> typecheck + |> withDiagnostics [] // SOURCE=MethodImplAttribute.AggressiveInlining.fs SCFLAGS="-a -g --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd MethodImplAttribute.AggressiveInlining.dll" # MethodImplAttribute.AggressiveInlining.fs [] diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index a9090fcf0..2a5977e61 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -391,6 +391,9 @@ module rec Compiler = let withLangVersion70 (cUnit: CompilationUnit) : CompilationUnit = withOptionsHelper [ "--langversion:7.0" ] "withLangVersion70 is only supported on F#" cUnit + let withLangVersion80 (cUnit: CompilationUnit) : CompilationUnit = + withOptionsHelper [ "--langversion:8.0" ] "withLangVersion80 is only supported on F#" cUnit + let withLangVersionPreview (cUnit: CompilationUnit) : CompilationUnit = withOptionsHelper [ "--langversion:preview" ] "withLangVersionPreview is only supported on F#" cUnit -- GitLab