Visitar URL original
Fix formatting a lambda expression with lifted operators by jnyrup · Pull Request #1714 · fluentassertions/fluentassertions · GitHub
Skip to content

Fix formatting a lambda expression with lifted operators - #1714

Merged
jnyrup merged 1 commit into
fluentassertions:masterfrom
jnyrup:PR1712
Oct 20, 2021
Merged

jnyrup merged 1 commit into
fluentassertions:masterfrom
jnyrup:PR1712

Conversation

@jnyrup

@jnyrup jnyrup commented Oct 20, 2021

Copy link
Copy Markdown
Member

My analysis in #1712 was not spot on.

Lifted operators are fine to use in Expressions, but only as long as we keep the LHS and RHS lifted.
The compiler converts e => e.Number > 43 into e => e.Number > Convert(43), which is the expression form of e => e.Number > (int?)43.
So the problem was that we tried to reduce (int?)43 to 43, which is not allowed.

This also add a check to avoid reducing already constant expressions.

This fixes #1712

@jnyrup
jnyrup merged commit 9e83a44 into fluentassertions:master Oct 20, 2021
@jnyrup
jnyrup deleted the PR1712 branch October 20, 2021 07:59
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.

ConstantSubExpressionReductionVisitor throws on lifted operator

2 participants