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

Implement CheckInvariant for C# AST #1634

Open
siegfriedpammer opened this issue Aug 12, 2019 · 1 comment
Open

Implement CheckInvariant for C# AST #1634

siegfriedpammer opened this issue Aug 12, 2019 · 1 comment
Labels
C# Decompiler The decompiler engine itself Enhancement Areas for improvement

Comments

@siegfriedpammer
Copy link
Member

While debugging #1628 I came across the situation that the assumption we use in some C# AST transforms (especially relevant for DeclareVariables), "that AstNode.FirstChild is always the first sub-expression/node that will be evaluated when the program is executed" is no longer true.

For example: BinaryOperatorExpression.Left == BinaryOperatorExpression.FirstChild is no longer true for some nodes in the tree in the final output visitor run.

This causes the problem that VariableToDeclare.FirstUse points to an expression in the middle of the operators and not to the first use.

Note that the DeclareVariables.Analyze run we do in PatternStatementTransform did not observe this problem.

We need some mechanism similar to the ILAst CheckInvariant structure to verify our assumptions about the structure of the C# AST.

@siegfriedpammer
Copy link
Member Author

siegfriedpammer commented Jun 14, 2020

#2033: This was caused because we generally assume that all C# Statement nodes that represent loops have their loop BlockContainer annotated. In this case the annotation was missing. An assertion could easily find such bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# Decompiler The decompiler engine itself Enhancement Areas for improvement
Projects
None yet
Development

No branches or pull requests

1 participant