mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 03:42:17 +00:00
![]() We have this idea of "rigid optional" fields to annotate record fields that must necessarily be optional. That avoids the admission of programs we cannot faithfully compile, like ``` f : {a: Str, b ? U64} f = {a: "b", b: 1} ``` We want to lose the rigidity restriction when a generalized symbol is used as at a specialized site; for example it should be possible to call `f : {x ? Str} -> {}` with both `{}` and `{x : Str}`, neither of which have a rigidly optional field unless they were to be annotated. Prior to this commit we would loosen the rigidity restriction upon specialization of a generalized type at a use site. However, what we really want to do is apply the loosening during calculation of generalization. The reason is that otherwise, we must make types that would be ground (like `{x ? Str} -> {}`) generalized just for the sake of the optional field annotation. But since the rigidity constraint is irrelevant after an annotated body has been checked, we can loosen the rigidity restriction then, which conveniently happens to coincide with the generalization calculation. Closes #3955 |
||
---|---|---|
.. | ||
helpers | ||
solve_expr.rs |