-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I'm using v4.0.0-preview4
The following method returns x != null && x != 4:
[Projectable(NullConditionalRewriteSupport = NullConditionalRewriteSupport.Rewrite)]
public static bool Test(this object? x)
=> x?.Equals(4) == false;Unfortunately, the generated code has a nasty bug!
It now returns x != null && x == 4 - inverting the result when x is not null.
static global::System.Linq.Expressions.Expression<global::System.Func<object, bool>> Expression()
{
return (object x) => x != null ? (x.Equals(4)) : (bool?)null == false;
}The ternary expression should be wrapped in parentheses before == false.
This seems somewhat similar to #115.
The corrected code should read:
static global::System.Linq.Expressions.Expression<global::System.Func<object, bool>> Expression()
{
return (object x) => (x != null ? (x.Equals(4)) : (bool?)null) == false;
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working