Skip to content
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

CR feedback on fixing constructor lookup when tuple created via "new" #10875

Merged
merged 1 commit into from
Apr 27, 2016

Conversation

VSadov
Copy link
Member

@VSadov VSadov commented Apr 26, 2016

CR feedback on fixing constructoir lookup when tuple created via "new"
see also
#10874
#10891

@VSadov
Copy link
Member Author

VSadov commented Apr 26, 2016

@dotnet/roslyn-compiler - please review

{
static void Main()
{
var x = new (int a, int b)(1, 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it also be useful to test constructor initializer? var x = new (int a, int b)(1, 2) { a = 3; b = 4 };

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not? :-)
Thanks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out we did not support constructor initializers for tuples at all.
Added positive/negative tests

@jcouv
Copy link
Member

jcouv commented Apr 26, 2016

LGTM


var comp = CreateCompilationWithMscorlib(source, parseOptions: TestOptions.Regular.WithTuplesFeature());
comp.VerifyDiagnostics(
// (6,22): error CS1729: 'ValueTuple<int, int>' does not contain a constructor that takes 3 arguments
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be using tuple notation for the type in the error message?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly.
Technically ctor belongs to the underlying type, so the error is correct - it tells exactly what type is missing a constructor.

I can see, however, how a custom error "this tuple cannot be constructed with N elements" could be more helpful.

Captured in #10874

@VSadov
Copy link
Member Author

VSadov commented Apr 26, 2016

@dotnet-bot test prtest/win/dbg/unit32 please
IO error

@VSadov
Copy link
Member Author

VSadov commented Apr 27, 2016

@dotnet-bot test prtest/win/dbg/unit32 please
nuget could not fetch threading dll

@gafter gafter changed the title CR feedback on fixing constructoir lookup when tuple created via "new" CR feedback on fixing constructor lookup when tuple created via "new" Apr 27, 2016
@gafter
Copy link
Member

gafter commented Apr 27, 2016

Recognizing this is a temporary solution that prevents a crash and this area is being reworked, LGTM. I suspect we may want to change the expected behavior of these tests after LDM review.

@VSadov VSadov merged commit d1e9e72 into dotnet:features/tuples Apr 27, 2016
@VSadov VSadov deleted the CRfollowUp branch June 29, 2017 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants