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

NullReferenceException in return statements on void methods #264

Closed
adrianoc opened this issue Feb 16, 2024 · 0 comments
Closed

NullReferenceException in return statements on void methods #264

adrianoc opened this issue Feb 16, 2024 · 0 comments
Labels
🐛 bug Something isn't working bug_reporter 🎃 good first issue Good for newcomers
Milestone

Comments

@adrianoc
Copy link
Owner

adrianoc commented Feb 16, 2024

Error

System.NullReferenceException: Object reference not set to an instance of an object.
at Cecilifier.Core.AST.ExpressionVisitor.VisitReturnStatement(ReturnStatementSyntax node) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/ExpressionVisitor.cs:line 144
at Microsoft.CodeAnalysis.CSharp.Syntax.ReturnStatementSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at Cecilifier.Core.AST.ExpressionVisitor.Visit(IVisitorContext ctx, String ilVar, SyntaxNode node) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/ExpressionVisitor.cs:line 128
at Cecilifier.Core.AST.StatementVisitor.VisitReturnStatement(ReturnStatementSyntax node) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/StatementVisitor.cs:line 173
at Microsoft.CodeAnalysis.CSharp.Syntax.ReturnStatementSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at Cecilifier.Core.AST.StatementVisitor.Visit(SyntaxNode node) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/StatementVisitor.cs:line 37
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitBlock(BlockSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax.Accept(CSharpSyntaxVisitor visitor)
at Cecilifier.Core.AST.StatementVisitor.Visit(IVisitorContext context, String ilVar, CSharpSyntaxNode node) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/StatementVisitor.cs:line 28
at Cecilifier.Core.AST.MethodDeclarationVisitor.VisitBlock(BlockSyntax node) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/MethodDeclarationVisitor.cs:line 57
at Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitMethodDeclaration(MethodDeclarationSyntax node)
at Cecilifier.Core.AST.MethodDeclarationVisitor.<>n__1(MethodDeclarationSyntax node)
at Cecilifier.Core.AST.MethodDeclarationVisitor.<>c__DisplayClass5_0.b__0(String _) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/MethodDeclarationVisitor.cs:line 70
at Cecilifier.Core.AST.SyntaxWalkerBase.WithCurrentMethod(String declaringTypeName, String localVariable, String methodName, String[] paramTypes, Action1 action) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/SyntaxWalkerBase.cs:line 253 at Cecilifier.Core.AST.MethodDeclarationVisitor.ProcessMethodDeclarationInternal(SyntaxNode node, String declaringTypeName, String variableName, IMethodSymbol methodSymbol, SyntaxTokenList modifiersTokens, String simpleName, String methodName, Boolean refReturn, Action1 runWithCurrent, SyntaxList1 attributes, SeparatedSyntaxList1 parameters, IList1 typeParameters) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/MethodDeclarationVisitor.cs:line 168 at Cecilifier.Core.AST.MethodDeclarationVisitor.ProcessMethodDeclaration[T](T node, String variableName, String simpleName, String fqName, Boolean refReturn, Action1 runWithCurrent, IList`1 typeParameters) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/MethodDeclarationVisitor.cs:line 198
at Cecilifier.Core.AST.MethodDeclarationVisitor.VisitMethodDeclaration(MethodDeclarationSyntax node) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/MethodDeclarationVisitor.cs:line 64
at Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at Cecilifier.Core.AST.TypeDeclarationVisitor.VisitMethodDeclaration(MethodDeclarationSyntax node) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/TypeDeclarationVisitor.cs:line 92
at Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitClassDeclaration(ClassDeclarationSyntax node)
at Cecilifier.Core.AST.TypeDeclarationVisitor.VisitClassDeclaration(ClassDeclarationSyntax node) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/TypeDeclarationVisitor.cs:line 41
at Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at Cecilifier.Core.AST.CompilationUnitVisitor.VisitDeclaredTypesSortedByDependencies() in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/CompilationUnitVisitor.cs:line 60
at Cecilifier.Core.AST.CompilationUnitVisitor.VisitCompilationUnit(CompilationUnitSyntax node) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/AST/CompilationUnitVisitor.cs:line 22
at Microsoft.CodeAnalysis.CSharp.Syntax.CompilationUnitSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at Cecilifier.Core.Cecilifier.Process(Stream content, CecilifierOptions options) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Core/Cecilifier.cs:line 51
at Cecilifier.Web.Startup.ProcessWebSocketAsync(WebSocket webSocket, Int32 remoteIpAddressHashCode, Byte[] buffer) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Web/Startup.cs:line 205
at Cecilifier.Web.Startup.ProcessWebSocketAsync(WebSocket webSocket, Int32 remoteIpAddressHashCode, Byte[] buffer) in /home/adriano/Projects/study/DotNet/Cecilifier/Cecilifier.Web/Startup.cs:line 235

Associated snippet:

class Foo
{
    void Scenario1(bool b)
    {
		return;
    }

    void Scenario2(bool b)
    {
        if (b) return;
    }

}
@adrianoc adrianoc added bug_reporter 🐛 bug Something isn't working 🎃 good first issue Good for newcomers labels Feb 16, 2024
@adrianoc adrianoc added this to the 2.10 milestone Mar 22, 2024
@adrianoc adrianoc added the wip Work In Progress label Apr 1, 2024
adrianoc added a commit that referenced this issue Apr 1, 2024
@adrianoc adrianoc added fixed-in-staging and removed wip Work In Progress labels Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working bug_reporter 🎃 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant