Skip to content

Commit 2b6fb2b

Browse files
authored
Short-circuiting expressions produce divergent types that propagate too far (#2700)
This is a fairly significant adjustment to how divergent types propagate. Previously, every time a divergent type encountered another type in propagation during inference, the divergence would cause type erasure, losing all the information about the type calculated so far. This means tuples, like `(<Int>, <Divergent>, <Double>)` would just become `<Divergent>` which would allow it to unify with any type, even tuples of a different arity. The same is true for arrays, where `[<Int>, <Divergent>, <Double>]` would not produce an error even though the type inference saw an Int and a Double that can't be in the same array. For the fix, this continues to propagate the bool that indicates a type is divergent without erasing the type. In specific cases, like the boundaries of blocks in if-expressions or the block in a specialization, the inference performs intentional type erasure similar to before. This allows for short-circuit expressions to have the right effects while still having better validation of types we can detect. Fixes #2697
1 parent e6b92db commit 2b6fb2b

File tree

3 files changed

+487
-123
lines changed

3 files changed

+487
-123
lines changed

0 commit comments

Comments
 (0)