Type Promotion on Record Attributes #4165
Labels
feature
Proposed language feature that solves one or more problems
field-promotion
Issues related to addressing the lack of field promotion
type-inference
Type inference, issues or improvements
When accessing a field in a record, the static analyzer is not able to do type promotion. If you destructure the fields into local variables, type promotion works.
See:
For fields on classes, type promotion is not possible, or at the very least would require some complex caveats and changes in the language spec: #1415
But records can't have getters and aren't sub-classable, so as far as I can tell, there should be no barriers to type promotion in theory. This would be very helpful to our team as currently we return records from functions regularly and ALWAYS destructure at call site to ensure type promotion, which in turn means adding more fields to a record bloats the call site namespace.
Partial destructuring would also solve our problem: #3964
The text was updated successfully, but these errors were encountered: