From 22344327abec9f23a7e71931e2cc686c73c7e923 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Tue, 9 Jul 2024 05:53:26 -0700 Subject: [PATCH] Fixes #17376 - Compiler hangs when compiling inline recursive invocation #17376 (#17394) --- docs/release-notes/.FSharp.Compiler.Service/9.0.100.md | 1 + src/Compiler/Optimize/Optimizer.fs | 5 ++++- .../RecursiveSafetyAnalysis/RecursiveSafetyAnalysis.fs | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md index bbe39d04166..7282b2d0b50 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md @@ -1,4 +1,5 @@ ### Fixed +* Compiler hangs when compiling inline recursive invocation ([Issue #17376](https://github.com/dotnet/fsharp/issues/17376), [PR #17394](https://github.com/dotnet/fsharp/pull/17394)) ### Added diff --git a/src/Compiler/Optimize/Optimizer.fs b/src/Compiler/Optimize/Optimizer.fs index 52b1dccc558..b2f5f654ce2 100644 --- a/src/Compiler/Optimize/Optimizer.fs +++ b/src/Compiler/Optimize/Optimizer.fs @@ -3137,9 +3137,12 @@ and OptimizeVal cenv env expr (v: ValRef, m) = | None -> if v.ShouldInline then - warning(Error(FSComp.SR.optFailedToInlineValue(v.DisplayName), m)) + match valInfoForVal.ValExprInfo with + | UnknownValue -> error(Error(FSComp.SR.optFailedToInlineValue(v.DisplayName), m)) + | _ -> warning(Error(FSComp.SR.optFailedToInlineValue(v.DisplayName), m)) if v.InlineIfLambda then warning(Error(FSComp.SR.optFailedToInlineSuggestedValue(v.DisplayName), m)) + expr, (AddValEqualityInfo g m v { Info=valInfoForVal.ValExprInfo HasEffect=false diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/InferenceProcedures/RecursiveSafetyAnalysis/RecursiveSafetyAnalysis.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/InferenceProcedures/RecursiveSafetyAnalysis/RecursiveSafetyAnalysis.fs index 9b9beecfdb0..52bf8601869 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/InferenceProcedures/RecursiveSafetyAnalysis/RecursiveSafetyAnalysis.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/InferenceProcedures/RecursiveSafetyAnalysis/RecursiveSafetyAnalysis.fs @@ -49,7 +49,7 @@ module RecursiveSafetyAnalysis = (Error 1114, Line 8, Col 15, Line 8, Col 25, "The value 'E_RecursiveInline.test' was marked inline but was not bound in the optimization environment") (Error 1113, Line 7, Col 16, Line 7, Col 20, "The value 'test' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible") (Warning 1116, Line 8, Col 15, Line 8, Col 25, "A value marked as 'inline' has an unexpected value") - (Warning 1118, Line 8, Col 15, Line 8, Col 25, "Failed to inline the value 'test' marked 'inline', perhaps because a recursive value was marked 'inline'") + (Error 1118, Line 8, Col 15, Line 8, Col 25, "Failed to inline the value 'test' marked 'inline', perhaps because a recursive value was marked 'inline'") ] // SOURCE=E_TypeDeclaration01.fs SCFLAGS="--langversion:5.0 --test:ErrorRanges" COMPILE_ONLY=1 # E_TypeDeclaration01.fs