-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Warn for is-pattern using a relational pattern with a known result. #42501
Changes from all commits
8e5126d
81d5459
c02a2c7
7d4d669
702515a
b30b15a
21e3571
e381464
149ffce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,6 +180,12 @@ BoundDecisionDagNode makeReplacement(BoundDecisionDagNode dag, Func<BoundDecisio | |
return d.Value == inputConstant; | ||
case BoundDagTypeTest d: | ||
return inputConstant.IsNull ? (bool?)false : null; | ||
case BoundDagRelationalTest d: | ||
var f = ValueSetFactory.ForSpecialType(input.Type.SpecialType); | ||
if (f is null) return null; | ||
// TODO: When ValueSetFactory has a method for comparing two values, use it. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
PROTOTYPE? #ByDesign There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. The code works correctly as is. This is a suggestion for a future optimization, which I expect to happen after merging into master. In reply to: 395854439 [](ancestors = 395854439) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be also filed as a follow-up issue? #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That wouldn't be particularly helpful to me, though I don't object to it. In reply to: 397252372 [](ancestors = 397252372) |
||
var set = f.Related(d.Relation.Operator(), d.Value); | ||
return set.Any(BinaryOperatorKind.Equal, inputConstant); | ||
default: | ||
throw ExceptionUtilities.UnexpectedValue(choice); | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider wrapping block in
if (fac is { }) { ... }
to avoid multiple?.
operators and== true
. #ByDesignThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that, but ended up having to repeat line 625 in multiple else clauses.
In reply to: 395854215 [](ancestors = 395854215)