fix: record spread works with named type aliases
Resolve type aliases (e.g. Player -> { pos: Vec2, speed: Float })
before checking if spread expression is a record type. Previously
{ ...p, field: val } failed with "must be a record type, got Player"
when the variable had a named type annotation.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2569,6 +2569,7 @@ impl TypeChecker {
|
|||||||
// Start with spread fields if present
|
// Start with spread fields if present
|
||||||
let mut field_types: Vec<(String, Type)> = if let Some(spread_expr) = spread {
|
let mut field_types: Vec<(String, Type)> = if let Some(spread_expr) = spread {
|
||||||
let spread_type = self.infer_expr(spread_expr);
|
let spread_type = self.infer_expr(spread_expr);
|
||||||
|
let spread_type = self.env.expand_type_alias(&spread_type);
|
||||||
match spread_type {
|
match spread_type {
|
||||||
Type::Record(spread_fields) => spread_fields,
|
Type::Record(spread_fields) => spread_fields,
|
||||||
_ => {
|
_ => {
|
||||||
|
|||||||
Reference in New Issue
Block a user