Skip to content

Conversation

@jcouv
Copy link
Member

@jcouv jcouv commented Jul 10, 2020

Fixes #45008
Corresponding spec update: dotnet/csharplang#3672

@jcouv jcouv added the Feature - Records Records label Jul 10, 2020
@jcouv jcouv self-assigned this Jul 10, 2020
@jcouv jcouv marked this pull request as ready for review July 13, 2020 17:07
@jcouv jcouv requested a review from a team as a code owner July 13, 2020 17:07
}
}

public sealed override bool IsImplicitlyDeclared
Copy link
Contributor

@AlekseyTs AlekseyTs Jul 14, 2020

Choose a reason for hiding this comment

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

public sealed override bool IsImplicitlyDeclared [](start = 8, length = 48)

It looks like this change is unnecessary, given the comment in SynthesizedRecordConstructor.cs. #Closed

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Jul 14, 2020

Done with review pass (iteration 2) #Closed

{
// we don't analyze synthesized void methods.
if ((method.IsImplicitlyDeclared && !method.IsScriptInitializer) ||
if ((method.IsImplicitlyDeclared && !method.IsScriptInitializer) || method is SynthesizedRecordConstructor ||
Copy link
Member Author

@jcouv jcouv Jul 14, 2020

Choose a reason for hiding this comment

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

📝 This is primarily to avoid cascading diagnostics (illustrated below), but also seems reasonable (why do extra analysis work on synthesized methods which we fully control?).

        [Fact, WorkItem(45008, "[https://github.com/dotnet/roslyn/issues/45008](https://github.com/dotnet/roslyn/issues/45008)")]
        public void PositionalMemberModifiers_RefOrOut()
        {
            var src = @"
record R(ref int P1, out int P2);
";

            var comp = CreateCompilation(src);
            comp.VerifyDiagnostics(
                // (2,9): error CS0177: The out parameter 'P2' must be assigned to before control leaves the current method
                // record R(ref int P1, out int P2);
                Diagnostic(ErrorCode.ERR_ParamUnassigned, "(ref int P1, out int P2)").WithArguments("P2").WithLocation(2, 9),
                // (2,10): error CS0631: ref and out are not valid in this context
                // record R(ref int P1, out int P2);
                Diagnostic(ErrorCode.ERR_IllegalRefParam, "ref").WithLocation(2, 10),
                // (2,22): error CS0631: ref and out are not valid in this context
                // record R(ref int P1, out int P2);
                Diagnostic(ErrorCode.ERR_IllegalRefParam, "out").WithLocation(2, 22)
                );
        }

Copy link
Contributor

Choose a reason for hiding this comment

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

why do extra analysis work on synthesized methods which we fully control?

We are not fully in control, there is user code in this method. Please revert this change. If you want to suppress specific diagnostics, suppress that specific diagnostics instead. It will be more robust to avoid making suppressions like that across the board. I personally, don't even think the diagnostics is cascading or should be suppressed, it reflects exactly what is happening, the parameter could be assigned in any of the initializers, or in base arguments.


In reply to: 454571864 [](ancestors = 454571864)

Copy link
Contributor

Choose a reason for hiding this comment

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

We might even come up with a scenario where the analysis produces useful diagnostics about code in initializers, or in base arguments.


In reply to: 455167934 [](ancestors = 455167934,454571864)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I understand now. We definitely want to analyze the base call.

@jcouv jcouv requested a review from AlekseyTs July 15, 2020 15:11
@AlekseyTs
Copy link
Contributor

AlekseyTs commented Jul 15, 2020

Done with review pass (iteration 5) #Closed

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (iteration 6), assuming CI is passing.

@jcouv jcouv closed this Jul 16, 2020
@jcouv jcouv reopened this Jul 16, 2020
@jcouv jcouv merged commit f2ddeba into dotnet:master Jul 16, 2020
@ghost ghost added this to the Next milestone Jul 16, 2020
@jcouv jcouv deleted the record-ref branch July 16, 2020 18:05
333fred added a commit to 333fred/roslyn that referenced this pull request Jul 17, 2020
* upstream/master: (86 commits)
  Better client / server logging (dotnet#46079)
  Fix OptProf config
  Update src/VisualStudio/LiveShare/Impl/AbstractGoToDefinitionWithFindUsagesServiceHandler.cs
  Do not execute RemoveUnnecessaryInlineSuppressions on generated code
  Update dependencies from https://github.com/dotnet/arcade build 20200715.6 (dotnet#46086)
  Use ISpanMapper before sending cross file results to LSP
  Add additional module initializers tests from review (dotnet#46020)
  Fix type in OptProf configuration
  bump to 500
  Fixed VS crash during implicit conversion of null object in nullable walker (dotnet#45974)
  Rename variable
  Fix KeyNotFound exception in RemoveUnnecessaryInlineSuppressionsDiagnosticAnalyzer
  Check modifiers on record positional members (dotnet#45898)
  Fix typos and link in Source Generators cookbook (dotnet#44372)
  Remove reference to non-existing VisualStudioInteractiveComponents.vsix from deployment VSIX. (dotnet#45979)
  Address feedback + fix tests
  Update dependencies from https://github.com/dotnet/roslyn build 20200711.1 (dotnet#45932)
  Make MetadataTypeName non-copyable
  Fix usage of GetService extension
  Consolidate service provider extensions
  ...
@JoeRobich JoeRobich modified the milestones: Next, 16.8.P1 Jul 20, 2020
333fred added a commit to 333fred/roslyn that referenced this pull request Jul 23, 2020
…to function-pointer-type-lookup

* upstream/features/function-pointers: (86 commits)
  Better client / server logging (dotnet#46079)
  Fix OptProf config
  Update src/VisualStudio/LiveShare/Impl/AbstractGoToDefinitionWithFindUsagesServiceHandler.cs
  Do not execute RemoveUnnecessaryInlineSuppressions on generated code
  Update dependencies from https://github.com/dotnet/arcade build 20200715.6 (dotnet#46086)
  Use ISpanMapper before sending cross file results to LSP
  Add additional module initializers tests from review (dotnet#46020)
  Fix type in OptProf configuration
  bump to 500
  Fixed VS crash during implicit conversion of null object in nullable walker (dotnet#45974)
  Rename variable
  Fix KeyNotFound exception in RemoveUnnecessaryInlineSuppressionsDiagnosticAnalyzer
  Check modifiers on record positional members (dotnet#45898)
  Fix typos and link in Source Generators cookbook (dotnet#44372)
  Remove reference to non-existing VisualStudioInteractiveComponents.vsix from deployment VSIX. (dotnet#45979)
  Address feedback + fix tests
  Update dependencies from https://github.com/dotnet/roslyn build 20200711.1 (dotnet#45932)
  Make MetadataTypeName non-copyable
  Fix usage of GetService extension
  Consolidate service provider extensions
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Records: Disallow ref kinds in positional members

4 participants