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

Ref returns/locals: Crash typing "ref" in any type #8402

Closed
dpoeschl opened this issue Feb 5, 2016 · 6 comments
Closed

Ref returns/locals: Crash typing "ref" in any type #8402

dpoeschl opened this issue Feb 5, 2016 · 6 comments

Comments

@dpoeschl
Copy link
Contributor

dpoeschl commented Feb 5, 2016

Tested against 842f5ad4309e370b763ee87de305ad012dcdda06 from #8030

Type ref inside an interface:

interface I
{

}

VS Crash, Null Reference Exception. The null variable in AddSkippedSyntax is the skippedSyntax passed in.

>   Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.ErrorReporting.FatalError.Report(System.Exception exception, System.Action<System.Exception> handler) Line 151 C#
    Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.DocumentState.IncrementallyParseTreeAsync(Roslyn.Utilities.ValueSource<Microsoft.CodeAnalysis.TreeAndVersion> oldTreeSource, Roslyn.Utilities.ValueSource<Microsoft.CodeAnalysis.TextAndVersion> newTextSource, System.Threading.CancellationToken cancellationToken) Line 180 C#
    [Resuming Async Method] 
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxParser.AddSkippedSyntax(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxToken target, Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode skippedSyntax, bool trailing) Line 839 C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxParser.AddTrailingSkippedSyntax<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode>(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode node, Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode skippedSyntax) Line 814   C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LanguageParser.SkipBadMemberListTokens(ref Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode previousNode) Line 1850   C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LanguageParser.SkipBadMemberListTokens(ref Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxToken openBrace, Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxListBuilder members) Line 1788    C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LanguageParser.ParseClassOrStructOrInterfaceDeclaration(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxListBuilder<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.AttributeListSyntax> attributes, Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxListBuilder modifiers) Line 1680 C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LanguageParser.ParseTypeDeclaration(Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxListBuilder<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.AttributeListSyntax> attributes, Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxListBuilder modifiers) Line 1599 C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LanguageParser.ParseMemberDeclarationOrStatement(Microsoft.CodeAnalysis.CSharp.SyntaxKind parentKind, string typeName) Line 2415  C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LanguageParser.ParseNamespaceBody(ref Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxToken openBrace, ref Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LanguageParser.NamespaceBodyBuilder body, ref Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxListBuilder initialBadNodes, Microsoft.CodeAnalysis.CSharp.SyntaxKind parentKind) Line 730   C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LanguageParser.ParseNamespaceDeclaration() Line 467   C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LanguageParser.ParseNamespaceBody(ref Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxToken openBrace, ref Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LanguageParser.NamespaceBodyBuilder body, ref Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxListBuilder initialBadNodes, Microsoft.CodeAnalysis.CSharp.SyntaxKind parentKind) Line 613   C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LanguageParser.ParseCompilationUnitCore() Line 372    C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LanguageParser.ParseWithStackGuard<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CompilationUnitSyntax>(System.Func<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CompilationUnitSyntax> parseFunc, System.Func<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CompilationUnitSyntax> createEmptyNodeFunc) Line 400  C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LanguageParser.ParseCompilationUnit() Line 355    C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.WithChanges(Microsoft.CodeAnalysis.Text.SourceText newText, System.Collections.Generic.IReadOnlyList<Microsoft.CodeAnalysis.Text.TextChangeRange> changes) Line 462    C#
    Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.WithChangedText(Microsoft.CodeAnalysis.Text.SourceText newText) Line 435   C#
    Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.DocumentState.IncrementallyParseTreeAsync(Roslyn.Utilities.ValueSource<Microsoft.CodeAnalysis.TreeAndVersion> oldTreeSource, Roslyn.Utilities.ValueSource<Microsoft.CodeAnalysis.TextAndVersion> newTextSource, System.Threading.CancellationToken cancellationToken) Line 174 C#
    Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.DocumentState.CreateLazyIncrementallyParsedTree.AnonymousMethod__0(System.Threading.CancellationToken c) Line 154  C#
    Microsoft.CodeAnalysis.Workspaces.dll!Roslyn.Utilities.AsyncLazy<Microsoft.CodeAnalysis.TreeAndVersion>.StartAsynchronousComputation(Roslyn.Utilities.AsyncLazy<Microsoft.CodeAnalysis.TreeAndVersion>.AsynchronousComputationToStart computationToStart, Roslyn.Utilities.AsyncLazy<Microsoft.CodeAnalysis.TreeAndVersion>.Request requestToCompleteSynchronously, System.Threading.CancellationToken callerCancellationToken) Line 378    C#
    Microsoft.CodeAnalysis.Workspaces.dll!Roslyn.Utilities.AsyncLazy<Microsoft.CodeAnalysis.TreeAndVersion>.GetValueAsync(System.Threading.CancellationToken cancellationToken) Line 331    C#
    Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.DocumentState.GetSyntaxTreeAsync(System.Threading.CancellationToken cancellationToken) Line 555    C#
    Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.Document.GetSyntaxTreeAsync(System.Threading.CancellationToken cancellationToken) Line 200 C#
    Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.Host.BackgroundParser.ParseDocumentAsync.AnonymousMethod__0() Line 172   C#
    [External Code] 
@dpoeschl
Copy link
Contributor Author

dpoeschl commented Feb 5, 2016

/cc: @VSadov

@dpoeschl
Copy link
Contributor Author

dpoeschl commented Feb 5, 2016

Also fails in abstract classes.

@dpoeschl dpoeschl changed the title Ref returns and locals: Crash typing "ref" in an interface Ref returns and locals: Crash typing "ref" in any type Feb 5, 2016
@dpoeschl
Copy link
Contributor Author

dpoeschl commented Feb 5, 2016

Actually, also failing in regular classes. It was working for me earlier because I was copy/pasting and editing the sample method, which works great.

public static ref S Choose(ref S s1, ref S s2)
{
    if () return ref s1;
    else return ref s2;
} 

@VSadov
Copy link
Member

VSadov commented Feb 5, 2016

Uhm :-(
Thanks for finding this !!

@dpoeschl dpoeschl added the Bug label Feb 5, 2016
@dpoeschl dpoeschl added this to the 2.0 milestone Feb 5, 2016
@dpoeschl dpoeschl changed the title Ref returns and locals: Crash typing "ref" in any type Ref returns/locals: Crash typing "ref" in any type Feb 6, 2016
@dpoeschl
Copy link
Contributor Author

dpoeschl commented Feb 7, 2016

Fix verified against VSadov@cca5f47

@VSadov
Copy link
Member

VSadov commented Feb 8, 2016

I guess this can be closed then.

@VSadov VSadov closed this as completed Feb 8, 2016
@dpoeschl dpoeschl added the Feature - Ref Locals and Returns Ref Locals and Returns label Feb 11, 2016
VSadov added a commit to VSadov/roslyn that referenced this issue Feb 18, 2016
member declaration parse should not be considered not advanced when "ref" keyword was consumed.

Fixes dotnet#8402
@dpoeschl dpoeschl modified the milestones: Language Feature Merging, 2.0 (Preview) Feb 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants