should pure-value cases narrow?
See original GitHub issueCurrently, a case with only values, such as case ("foo"|"bar")
doesn’t narrow the type of the switched variable. After #4402 that’s inconsistent and special-casey. Also it would be useful to narrow the type when you have multiple values listed in a single case
.
I think we should change this. However, it would be a source code breaking change, since in 1.x we allowed you to have a variable switch expression if all the cases were value cases. We would have to close that loophole.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
RPV: Pure Value Is Outpacing The S&P 500 This Year ...
This article will compare RPV's strategy and fundamentals with a more popular broad-based value ETF and make the case that as long as ......
Read more >S&P U.S. Style Indices Methodology
The second need is for narrow, style-pure indices. The Style index series divides the ... Number of Stocks in S&P SmallCap 600 Pure...
Read more >How to properly force evaluation of pure value in IO monad?
Daniel Wagner's answer is fine for this use-case, but sometimes it's also beneficial to just evaluate the spine of a list and leave...
Read more >Russell Pure Style Indexes
Russell 1000® Pure Value Index. Small Cap. Russell 2000® Pure Growth Index. Russell 2000® Pure Value Index. Mid Cap. Russell Midcap Pure Growth...
Read more >Super Thinnest iPhone XS Max Slim Cases without Adding ...
If you are not dwelling in a location that is surrounded by hazardous materials all around, then a thin case is something you...
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
Alright, @ePaul, so I figured out a way to implement this. It’s kinda nasty but in a way, but not actually fragile. It’s on the
7248
branch.Still, I will probably add a deprecation warning to the case of
switch
ing avariable
, since this behavior is pretty inconsistent with howis
andexists
conditions treatvariable
s.Spec updated, closing.