diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index ec0c4d6686f..16bfa69bd3d 100644 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -1066,7 +1066,7 @@ let AbstractLazyModulInfoByHiding isAssemblyBoundary mhi = ValInfos = ValInfos(ss.ValInfos.Entries |> Seq.filter (fun (vref,_) -> not (hiddenVal vref.Deref)) - |> Seq.map (fun (vref,e) -> check (* "its implementation uses a binding hidden by a signature" m *) vref (abstractValInfo e) )) } + |> Seq.map (fun (vref,e) -> (vref, (abstractValInfo e) ))) } and abstractLazyModulInfo (ss:LazyModuleInfo) = ss.Force() |> abstractModulInfo |> notlazy @@ -2749,7 +2749,14 @@ and OptimizeLambdas (vspec: Val option) cenv env topValInfo e ety = let valu = match baseValOpt with | None -> CurriedLambdaValue (lambdaId,arities,bsize,expr',ety) - | _ -> UnknownValue + | Some baseVal -> + let fvs = freeInExpr CollectLocals body' + if fvs.UsesMethodLocalConstructs || fvs.FreeLocals.Contains baseVal then + UnknownValue + else + let expr2 = mkMemberLambdas m tps ctorThisValOpt None vsl (body',bodyty) + CurriedLambdaValue (lambdaId,arities,bsize,expr2,ety) + expr', { TotalSize=bsize + (if isTopLevel then methodDefnTotalSize else closureTotalSize); (* estimate size of new syntactic closure - expensive, in contrast to a method *) FunctionSize=1; @@ -3055,7 +3062,7 @@ and OptimizeBinding cenv isRec env (TBind(v,e,spBind)) = then {einfo with Info=UnknownValue} else einfo if v.MustInline && IsPartialExprVal einfo.Info then - errorR(InternalError("the mustinline value '"^v.LogicalName^"' was not inferred to have a known value",v.Range)); + errorR(NumberedError(FSComp.SR.optValueMarkedInlineButIncomplete(v.DisplayName), v.Range)) #if DEBUG if verboseOptimizations then dprintf "val %s gets opt info %s\n" (showL(valL v)) (showL(exprValueInfoL cenv.g einfo.Info)); #endif diff --git a/tests/.gitignore b/tests/.gitignore index eca5ba1118f..531297fba98 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,4 +1,6 @@ FSharp_* FSharpQA_* CoreUnit_* -TestResults \ No newline at end of file +TestResults + +**/_perm.txt \ No newline at end of file diff --git a/tests/fsharp/core/subtype/test.fsx b/tests/fsharp/core/subtype/test.fsx index 321c202c963..4b594f3f4c1 100644 --- a/tests/fsharp/core/subtype/test.fsx +++ b/tests/fsharp/core/subtype/test.fsx @@ -1696,6 +1696,25 @@ module RecordPropertyConstraintTests = check "ckjwnewk" (f8()) (System.TimeSpan.FromSeconds 2.0) // after mutation check "ckjwnewk" (f10()) "Gary" +// See https://github.com/Microsoft/visualfsharp/issues/740 - inlining on subtypes was not allowed +module InliningOnSubTypes1 = + type A() = + static member inline dosomething() = () + + type B() = + inherit A() + member inline this.SomethingElse a = a + 10 + member inline this.SomethingElse2 a b = a + b + 10 + + let f () = + let b = B() + let x1 = b.SomethingElse 3 + let x2 = b.SomethingElse2 3 4 + (x1, x2) + do check "clkewlijwlkw" (f()) (13, 17) + + + // See https://github.com/Microsoft/visualfsharp/issues/238 module GenericPropertyConstraintSolvedByRecord = diff --git a/tests/fsharp/optimize/.gitignore b/tests/fsharp/optimize/.gitignore index 2de025a1737..1ec792c9c34 100644 --- a/tests/fsharp/optimize/.gitignore +++ b/tests/fsharp/optimize/.gitignore @@ -8,6 +8,8 @@ inline/FSharpOptimizationData.* inline/FSharpSignatureData.* inline/*.il inline/*.res +inline/*.err +inline/*.diff stats/*.resources stats/*.il diff --git a/tests/fsharp/optimize/inline/build.bat b/tests/fsharp/optimize/inline/build.bat index a75d70755fa..4745a80026f 100644 --- a/tests/fsharp/optimize/inline/build.bat +++ b/tests/fsharp/optimize/inline/build.bat @@ -28,6 +28,9 @@ if ERRORLEVEL 1 goto Error "%FSC%" %fsc_flags% --optimize -o:test--optimize.exe -g test.fs -r:lib--optimize.dll -r:lib3--optimize.dll if ERRORLEVEL 1 goto Error +call ..\..\single-neg-test.bat neg01 +@if ERRORLEVEL 1 goto Error + :Ok echo Built fsharp %~f0 ok. echo. > build.ok diff --git a/tests/fsharp/optimize/inline/neg01.bsl b/tests/fsharp/optimize/inline/neg01.bsl new file mode 100644 index 00000000000..529c3e96a77 --- /dev/null +++ b/tests/fsharp/optimize/inline/neg01.bsl @@ -0,0 +1,4 @@ + +neg01.fs(16,22,16,24): optimize error FS1113: The value 's2' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible + +neg01.fs(16,22,16,24): optimize error FS1113: The value 's2' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible diff --git a/tests/fsharp/optimize/inline/neg01.fs b/tests/fsharp/optimize/inline/neg01.fs new file mode 100644 index 00000000000..9953715a42c --- /dev/null +++ b/tests/fsharp/optimize/inline/neg01.fs @@ -0,0 +1,17 @@ +namespace Neg01 + +(* Optimizer should not throw InternalError when it + encounters an inline method that references `base`, + a compilation error should be reported instead. + See issue: https://github.com/Microsoft/visualfsharp/issues/740 *) + +type Base<'T>() = + + member __.s() = () + +type Class<'T>() = + inherit Base<'T>() + + member inline __.Bar x = x + member inline __.s2() = base.s() + member inline this.s3() = this.Bar 1 |> ignore diff --git a/tests/fsharp/typecheck/.gitignore b/tests/fsharp/typecheck/.gitignore index 4bfefa6abed..68d1a2ceee0 100644 --- a/tests/fsharp/typecheck/.gitignore +++ b/tests/fsharp/typecheck/.gitignore @@ -1,7 +1,9 @@ sigs/*.err sigs/*.vserr -sigs/pos*.dll -sigs/pos*.exe +sigs/*.dll +sigs/*.exe +sigs/*.diff +sigs/*.vsdiff full-rank-arrays/HighRankArrayTests.dll