or-pattern narrowed type is too restrictive #4405
Unanswered
alrz
asked this question in
Language Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently all of these patterns only check for
int and > 0
Flipping types changes the codegen due to implicit conversions, but effectively all of the checks are wrong. (sharplab)
I would expect we generate the code equivalent to
o is A and > 0 or B and > 0
regardless of the order of types (we will emit>
twice, one per each type).Any pattern that is sensitive to the input type would be affected, this includes list patterns.
Note that the list pattern codegen for each type would be different, but per current spec, the narrowed type here is
object
and the code won't compile.The alternative is that we repeat the pattern for each type.
Beta Was this translation helpful? Give feedback.
All reactions