Describe the Bug
I recently fixed #793 (contextual typing with union hints) by changing the logic for hint decomposition to iterate over union members, trying every one. This is fairly expensive, and I had to add a couple hard-coded limits for the maximum union size we'll iterate over. There are a few optimizations we can try to make this more performant (ideas courtesy of @samwgoldman):
- pre-process expressions to separate “contextually sensitive” from non, avoiding even attempting contextual typing for expressions which don’t need it. These expressions can just be inferred once.
- a normalization process for hints which can simplify hint type. For example, a hint with the form Any | t can match any expression, so we can simplify the hint away.
- a matching/filtering process during the contextual push down which can filter contexts which are not useful.
- making the process of decomposing hints lazy, to avoid the computation when the hint would go unused
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
No response
Describe the Bug
I recently fixed #793 (contextual typing with union hints) by changing the logic for hint decomposition to iterate over union members, trying every one. This is fairly expensive, and I had to add a couple hard-coded limits for the maximum union size we'll iterate over. There are a few optimizations we can try to make this more performant (ideas courtesy of @samwgoldman):
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
No response