mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Fix index type intersections with x["prop"] syntax
This commit is contained in:
parent
118f6ed3c6
commit
1260ca5969
1 changed files with 14 additions and 0 deletions
|
@ -3412,6 +3412,20 @@ TypeId TypeChecker::checkLValueBinding(const ScopePtr& scope, const AstExprIndex
|
|||
return prop->type();
|
||||
}
|
||||
}
|
||||
else if (get<IntersectionType>(exprType))
|
||||
{
|
||||
Name name = std::string(value->value.data, value->value.size);
|
||||
|
||||
if (std::optional<TypeId> ty = getIndexTypeFromType(scope, exprType, name, expr.location, /* addErrors= */ false))
|
||||
return *ty;
|
||||
|
||||
// If intersection has a table part, report that it cannot be extended just as a sealed table
|
||||
if (isTableIntersection(exprType))
|
||||
{
|
||||
reportError(TypeError{expr.location, CannotExtendTable{exprType, CannotExtendTable::Property, name}});
|
||||
return errorRecoveryType(scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue