Add lint check for wildcards in inline match
#23642
WojciechMazur
started this conversation in
Feature Requests
Replies: 2 comments
-
I wonder if this should actually be the default. Can we ever inline properly with a wildcard present? |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is standard behavior of an |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
Combining wildcards
case _
andinline match
can lead to unexpected behaviours when providing runtime computed values.Here's an example:
In this example if we ch about
stringValue
being computed at compile time we can easily introduce logic bugs to our code base.To prevent that we need to either:
value
is a cosnt usingscala.ompiletime.requireConst
Both of these have it's own drawbacks, and each of these rules is easy to forget about. I propose we try to introduce a lint check under a flag (e.g.
-Winline-match-wildcard
) to detect and warn about such usages.Beta Was this translation helpful? Give feedback.
All reactions