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

Make handling of MatchExpression more robust #768

Merged
merged 5 commits into from
Mar 4, 2019

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Mar 4, 2019

This is extracted from, and required by, #767. Moq should be able to process expressions containing a MatchExpression more or less everywhere except during compilation (because it doesn't carry enough information to properly allow that scenario).

@stakx stakx added this to the 4.11.0 milestone Mar 4, 2019
@@ -33,7 +33,7 @@ public static Expression PartialEval(Expression expression, Func<Expression, boo
/// <returns>A new tree with sub-trees evaluated and replaced.</returns>
public static Expression PartialEval(Expression expression)
{
return PartialEval(expression, e => e.NodeType != ExpressionType.Parameter);
return PartialEval(expression, e => e.NodeType != ExpressionType.Parameter && !(e is MatchExpression));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of this change, perhaps it would be better to add a check right inside Evaluator that recognizes irreducible Extension nodes.

@@ -334,6 +334,9 @@ private static bool PartialMatcherAwareEval_ShouldEvaluate(Expression expression
case ExpressionType.Parameter:
return false;

case ExpressionType.Extension:
return !(expression is MatchExpression);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of this change, perhaps it would be better to add a check right inside Evaluator that recognizes irreducible Extension nodes.

@stakx stakx removed the draft label Mar 4, 2019
@stakx stakx merged commit 41ff3d6 into devlooped:master Mar 4, 2019
@stakx stakx deleted the matchexpression branch March 4, 2019 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant