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

Address test plan for target-typed new #29167

Merged

Conversation

alrz
Copy link
Member

@alrz alrz commented Aug 8, 2018

Follow-up #25196
Test plan: #28489

@alrz alrz requested review from a team as code owners August 8, 2018 16:02
@alrz alrz mentioned this pull request Aug 8, 2018
@alrz
Copy link
Member Author

alrz commented Aug 8, 2018

Please review #25196 before reviewing this.

@alrz
Copy link
Member Author

alrz commented Aug 8, 2018

Binary operators are not wholly tested yet. Pending design decision on how we want them to behave.

See #28489 (comment)

@alrz alrz force-pushed the features/target-typed-new2 branch 2 times, most recently from 0de6176 to 4319b86 Compare August 8, 2018 16:41
@gafter
Copy link
Member

gafter commented Aug 8, 2018

Could you rebase please? I merged the previous PR, and for some reason those deltas are showing up here.

@gafter gafter added this to the 16.0 milestone Aug 8, 2018
@alrz alrz force-pushed the features/target-typed-new2 branch from 4319b86 to 30507d5 Compare August 8, 2018 17:14
@jcouv
Copy link
Member

jcouv commented Aug 8, 2018

                Error(diagnostics, ErrorCode.ERR_NewWithTupleTypeSyntax, syntax, type);

So, I got a bit confused on tuples. Latest LDM notes say they should be allowed.
https://github.com/dotnet/csharplang/blob/master/meetings/2018/LDM-2018-06-25.md#unconstructable-types

Can you fix or add a PROTOTYPE(target-typed-new): ... comment as a reminder? #Closed


Refers to: src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs:230 in 30507d5. [](commit_id = 30507d5, deletion_comment = False)

@jcouv
Copy link
Member

jcouv commented Aug 9, 2018

            Error(diagnostics, ErrorCode.ERR_BadOpOnNullOrDefault, node, operatorText, operand.Display);

nit: consider renaming ERR_BadOpOnNullOrDefault. Maybe ERR_BadOpOnTypelessExpression. #Closed


Refers to: src/Compilers/CSharp/Portable/Binder/Binder_Operators.cs:2279 in 30507d5. [](commit_id = 30507d5, deletion_comment = False)

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

Code change looks good (iteration 4). I'll finish reviewing the tests tomorrow. Thanks

@jcouv
Copy link
Member

jcouv commented Aug 9, 2018

}

Consider restoring the compilation/execution/validation of the expressions.


Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/TargetTypedNewTests.cs:58 in 30507d5. [](commit_id = 30507d5, deletion_comment = False)

@jcouv
Copy link
Member

jcouv commented Aug 9, 2018

    public void TestArguments_Params()

If not already tested, another params scenario would be interesting: void M(params int[] p) invoked with M(new()) or M(new[] { new() }). (I expect errors in both cases)

Thinking about array initializers, here's another idea: new int[] { new() } (ok)


Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/TargetTypedNewTests.cs:172 in 30507d5. [](commit_id = 30507d5, deletion_comment = False)

@jcouv
Copy link
Member

jcouv commented Aug 9, 2018

    M((new(), new()), new C());

Nice test case! #Closed


Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/TargetTypedNewTests.cs:288 in 30507d5. [](commit_id = 30507d5, deletion_comment = False)

@jcouv
Copy link
Member

jcouv commented Aug 9, 2018

        comp.VerifyEmitDiagnostics();

Consider putting CompileAndVerify back (with some verification of data stored in dictionaries). #Closed


Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/TargetTypedNewTests.cs:527 in 30507d5. [](commit_id = 30507d5, deletion_comment = False)

@alrz
Copy link
Member Author

alrz commented Dec 15, 2018

            // The old native compiler ignores ref/out in a delegate creation expression.
            // For compatibility we implement the same bug except in strict mode.
            // Note: Some others should still be rejected when ref/out present. See RefMustBeObeyed.

Do we need to do this in new()? since it's for compatibility, I think it's safe to not do that. Also, doing so would complicate argument binding because we bind arguments early before knowing the type.

@jcouv jcouv modified the milestones: 16.0, 16.1.P1 Jan 4, 2019
Copy link
Member

@gafter gafter left a comment

Choose a reason for hiding this comment

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

Looks great. We'll turn the PROTOTYPE comments into an issue and deal with that separately.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks

@jcouv
Copy link
Member

jcouv commented Mar 21, 2019

@gafter for second sign-off. Thanks

I'll close and re-open the PR to kick CI.

@jcouv jcouv closed this Mar 21, 2019
@jcouv jcouv reopened this Mar 21, 2019
@jcouv
Copy link
Member

jcouv commented Apr 2, 2019

I'll close and re-open the PR to kick CI.

@jcouv jcouv closed this Apr 2, 2019
@jcouv jcouv reopened this Apr 2, 2019
@gafter gafter modified the milestones: 16.1.P1, 16.1.P3 Apr 9, 2019
@jcouv jcouv closed this Apr 18, 2019
@jcouv jcouv reopened this Apr 18, 2019
@jcouv
Copy link
Member

jcouv commented Apr 23, 2019

We'll need to refresh the features/target-typed-new branch with latest bits from master before we can merge this PR (that's why CI isn't working in this PR).

@jinujoseph jinujoseph modified the milestones: 16.1.P3, 16.1 Apr 24, 2019
@jinujoseph jinujoseph modified the milestones: 16.1, 16.3 Jun 9, 2019
@gafter gafter modified the milestones: 16.3, Compiler.Next Jul 15, 2019
Copy link
Member

@gafter gafter left a comment

Choose a reason for hiding this comment

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

:shipit:

@gafter gafter merged commit a46c4e1 into dotnet:features/target-typed-new Jul 15, 2019
@alrz alrz deleted the features/target-typed-new2 branch July 18, 2019 10:31
@alrz
Copy link
Member Author

alrz commented Jul 20, 2019

I attempted a merge from compilerNext and turns out I'll have to read the parser from the top.

I noticed there's an assert to avoid lookaheads for new expressions,

Debug.Assert(mode != ParseTypeMode.NewExpression);

@gafter do you intend to keep this for new() as well? iow with the new parser logic, do we still need lookaheads for this work?

@gafter
Copy link
Member

gafter commented Jul 25, 2019

I don't recall the reason for the restriction/assertion. I believe the parser does require look-ahead for parsing types in patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee. New Language Feature - Target-Typed New `new (args)` gets the created type inferred from context
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants