Wrong match case selected
See original GitHub issueCompiler version
3.2.0
Minimized code
class Baz:
inline def foo: Int = bar(zero)
inline def bar(inline i: Int): Int = inline i match
case 0 => 0
case _ => 1
private inline def zero = 0
println(Baz().foo)
Output
1
Expectation
0
See also #15893
Issue Analytics
- State:
- Created a year ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
How to make case sensitive match - SpreadsheetWeb
Start with =MATCH( function · Type TRUE, to search for matched values · Continue with EXACT( function · Select the reference that contains...
Read more >Find.MatchCase property (Word) - Microsoft Learn
In this article. True if the find operation is case-sensitive. The default is False. Read/write Boolean.
Read more >Thread: Match Case in Find does not work. - VBA Express
I am attempting to find text with no regards to case. ".MatchCase = False" (or true) does not work. This is what I...
Read more >INDEX MATCH – Case sensitive - Get Digital Help
The MATCH function finds a specific value in an array or cell range and returns its location, a number representing the position.
Read more >Excel MATCH Function Error Troubleshooting Examples
Sometimes, a MATCH formula returns an #N/A error, even if the value you're looking for is in the lookup table. The reason for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s a little confusing to me that “disjointness” is a factor in match type reduction but not in inline matches. Makes it more work to remember the different semantics. I’m guessing it’s required or perhaps much preferred.
@odersky thank you for clarifying.
A few more observations:
This behavior (and how it differs from match type reduction) doesn’t currently seem to be fully documented.
One might naively assume the inline match to be equivalent to
inline if i == 0 then 0 else 1
(but the latter leads to a compile-time error).In both cases, it also seems at odds with the part of the documentation that says
It guarantees that inlining actually happens instead of being best-effort
. According to that statement, one might naively assume code reduction to proceed somewhat as follows:-->
(becausezero
is guaranteed to be inlined)-->
(becausebar
is guaranteed to be inlined)-->
(inline if
reduction)-->
(becausefoo
is guaranteed to be inlined)