-
Notifications
You must be signed in to change notification settings - Fork 788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #17797 -- Realsig+ generates nested closures with incorrect Generic arguments #17877
base: main
Are you sure you want to change the base?
Conversation
❗ Release notes required
|
35a8aad
to
a7eeda8
Compare
bb06ffa
to
1d562ef
Compare
e13abad
to
ef80877
Compare
376285d
to
d2ff439
Compare
[<InlineData(false, false)>] // Regular NoOptimize | ||
[<Theory>] | ||
let ``BigTuples`` (realSig, optimize) = | ||
let withOptimization compilation = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block is repeated across tests, can be moved on top of the file:
|> withRealSig realSig |> withOptimize optimize
else compilation |> withNoOptimize | ||
|
||
FSharp """ | ||
namespace Internal.Utilities.Collections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code snippet is in my opinion big enough to justify living in its own file instead of being in an inline string.
IL_0012: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<class [FSharp.Core]Microsoft.FSharp.Core.Unit,int32>::Invoke(!0) | ||
IL_0017: ret | ||
IL_0008: ldnull | ||
IL_0009: call int32 Match01/Test1::CompareTo$cont@4(class Match01/Test1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this diff is THE thing we have wanted to address in the dotnet/performance regression with structs, right?
i.e. calling a function directly as opposed to going via new closure allocation+invocation.
.maxstack 4 | ||
.locals init (class Match01/Test1 V_0, | ||
class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<class [FSharp.Core]Microsoft.FSharp.Core.Unit,int32> V_1) | ||
.maxstack 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing the amount of locals below, is the .maxstack 5 correct here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, you do plan do run ilverify and it will complain if there is any point in time for the program where it would needed more.
(just remembering we do reuse locals of same type, so I assume there must be some point in execution where more things are stacked)
@@ -1104,7 +1104,7 @@ type Generic1InGeneric1<'T>() = | |||
extends [runtime]System.Object | |||
{ | |||
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) | |||
.class auto autochar sealed nested assembly beforefieldinit specialname clo@7<A> | |||
.class auto autochar sealed nested assembly beforefieldinit specialname clo@7<T,A> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is closure heavy, can we have it ilverified too?
Fsx """// #Regression #Conformance #LexicalAnalysis #Operators | ||
// Regression test for FSHARP1.0:4805 | ||
// We are not really after the actual error messages here (some of them have been omitted), rather we | ||
// want to verify we do not crash! | ||
//<Expects status="warning" id="FS0064">This construct causes code to be less generic than indicated by the type annotations\. The type variable 'S has been constrained to be type 'int'</Expects> | ||
//<Expects status="error" id="FS0670">This code is not sufficiently generic\. The type variable \^T when \^T : \(static member \( \+ \) : \^T \* \^T -> \^a\) could not be generalized because it would escape its scope</Expects> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fsx """// #Regression #Conformance #LexicalAnalysis #Operators | |
// Regression test for FSHARP1.0:4805 | |
// We are not really after the actual error messages here (some of them have been omitted), rather we | |
// want to verify we do not crash! | |
//<Expects status="warning" id="FS0064">This construct causes code to be less generic than indicated by the type annotations\. The type variable 'S has been constrained to be type 'int'</Expects> | |
//<Expects status="error" id="FS0670">This code is not sufficiently generic\. The type variable \^T when \^T : \(static member \( \+ \) : \^T \* \^T -> \^a\) could not be generalized because it would escape its scope</Expects> | |
Fsx """ |
@@ -17,59 +18,59 @@ module ComputedCollections = | |||
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Int32RangeArrays.fs"|])>] | |||
let ``Int32RangeArrays_fs`` compilation = | |||
compilation | |||
|> verifyCompilation | |||
|> verifyCompilation false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am okay with this PR not turning realSig's default to true yet.
But when we do, I think we should be running as much tests as possible with the same default.
Will it be a painful update, or was there another reason for using "false" here?
My review is finished, but let's wait for the ilverify for realsig as a CI step as well. |
When realsig+ is specified we generate closures as nested classes rather than classes at the same level as the class that the closures are for. This eliminates the need for members of the class to be internal allowing us to make the members private to reflect their source visibility.
Issue 17797 occurs because the closures were generated without the generic parameters. This fix addresses that by getting the generic parameters from the argument/typar environment.