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
Unexpected Compiler Errors with Nullable Value Tuples #5217
Comments
Accidentally confirmed that this is still an issue.
Though there's a simple workaround: create an explicit struct instead. abstract (string Name, int Value)? GetStuff(); do it like this: struct Stuff
{
public string Name;
public int Value;
}
abstract Stuff? GetStuff(); override this.GetStuff() =
Nullable(Stuff(Name="Answer", Value=42)) |
Treating as duplicate of #7618 |
Usage of struct tuples (
struct (0,0)
) with theSystem.Nullable<T>
type seems to cause unexpected compiler errors with F#. When attempting to directly instantiate aNullable(struct (0,0))
, the errorA generic construct requires that the type 'struct (a * b)' have a public default constructor
is reported. When attempting to instantiate aNullable
using a struct tuple bound to an identifier, such asNullable(x)
, the errorinternal error: tcrefOfAppTy (Failure)
is thrown. Simply unboxing the struct tuple as aValueTuple<int,int>
seems to resolve both of these errors.Repro steps
This produces the error:
error FS0001: A generic construct requires that the type 'struct ('a * 'b)' have a public default constructor
This produces the error
error FS0073: internal error: tcrefOfAppTy (Failure)
This executes without errors.
Expected behavior
Creating instances of Nullable with a struct tuple should work without error, equivalent to the behavior for using System.ValueTuple.
Actual behavior
Different compiler errors are reported when attempting to instantiate a Nullable with a struct tuple.
Known workarounds
Unboxing the struct tuple to a System.ValueTuple resolves the compiler errors and executes as expected.
Related information
Please see this StackOverflow post for the original report of this behavior.
Windows 10
.NET Framework 4.7.1
Visual Studio 2017
The text was updated successfully, but these errors were encountered: