infer "of" narrowing
See original GitHub issueLet’s face it: it’s totally weird that this is well-typed:
alias Bool => \Itrue|\Ifalse;
void fun(Bool bool) {}
Boolean t = true;
fun(t of Bool);
But this is not:
alias Bool => \Itrue|\Ifalse;
void fun(Bool bool) {}
Boolean t = true;
fun(t);
In such cases, instead of producing an error, we could, completely safely and reasonably, just infer the of Bool
bit. I’m conflicted about that because while it works perfectly nicely here, I guess it would create the expectation in the user’s head that \Itrue|\Ifalse
and Boolean
are the same type, which is an expectation that is violated as soon as these types are used as type arguments. (A List<Boolean>
is not a List<\Itrue|\Ifalse>
in Ceylon!
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Documentation - Narrowing - TypeScript
(The latter has the advantage that TypeScript infers a narrow literal boolean type true , while inferring the first as type boolean .)...
Read more >Narrowing: Meaning, Examples & Types | StudySmarter
Narrowing is a type of semantic change in which the meaning of a word becomes less generalised over time. Narrowing may also be...
Read more >TypeScript type inference/narrowing challenge - Stack Overflow
I'd like to remove the need to explicitly narrow the type of the message passed to the message handler (where /*REMOVE THIS TYPE...
Read more >Narrowing Types in TypeScript - Formidable Labs
Type narrowing is just what it sounds like—narrowing down a general ... is clever enough to infer the narrowing from our conditional logic....
Read more >Inverse Narrowing for the Inductive Inference of Functional ...
Inverse Narrowing for the Inductive Inference of Functional Logic Programs1. J. Hernandez-Orallo & M.J. Ramirez-Quintana. DSIC, Universitat Politècnica de ...
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
Even if the compiler didn’t infer the
of Bool
, it could still generate an error message which suggests it as a possible fix!Ah, that’s the one. It would be nice to dial it back a bit for refinement: