-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for ClassType indexer in definition files #949
Add support for ClassType indexer in definition files #949
Conversation
@@ -1151,6 +1152,15 @@ ControlFlow ConstraintGraphBuilder::visit(const ScopePtr& scope, AstStatDeclareC | |||
|
|||
scope->exportedTypeBindings[className] = TypeFun{{}, classTy}; | |||
|
|||
if (FFlag::LuauParseDeclareClassIndexer && declaredClass->indexer) | |||
{ | |||
// TODO: Recursion limit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at ConstraintGraphBuilder::checkPack(const ScopePtr&, AstExpr*, const std::vector<std::optional<TypeId>>&)
for an example of how to implement this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was copied from the AstTypeTable code which has the same TODO comment, but yeah I can add it in
https://github.com/Roblox/luau/blob/3ecd3a82abe6682988112cd6eb7326a67ebbc47f/Analysis/src/ConstraintGraphBuilder.cpp#L2494-L2501
if (recursionCount >= FInt::LuauCheckRecursionLimit) | ||
{ | ||
reportCodeTooComplex(declaredClass->indexer->location); | ||
} | ||
else | ||
{ | ||
ctv->indexer = TableIndexer{ | ||
resolveType(scope, declaredClass->indexer->indexType, /* inTypeArguments */ false), | ||
resolveType(scope, declaredClass->indexer->resultType, /* inTypeArguments */ false), | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its not completely similar to checkPack
so i put it as an if-else instead of an early return. I assume we should continue processing the CTV even if the indexer is too complex
* Definition files can now ascribe indexers to class types. (#949) * Remove --compile support from the REPL. You can just use luau-compile instead. * When an exception is thrown during parallel typechecking (usually an ICE), we now gracefully stop typechecking and drain active workers before rethrowing the exception. New solver * Include more source location information when we hit an internal compiler error * Improve the logic that simplifies intersections of tables JIT * Save testable type annotations to bytecode * Improve block placement for linearized blocks * Add support for lea reg, [rip+offset] for labels * Unify X64 and A64 codegen for RETURN * Outline interrupt handlers for X64 * Remove global rArgN in favor of build.abi * Change A64 INTERRUPT lowering to match X64 --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
* Definition files can now ascribe indexers to class types. (luau-lang/luau#949) * Remove --compile support from the REPL. You can just use luau-compile instead. * When an exception is thrown during parallel typechecking (usually an ICE), we now gracefully stop typechecking and drain active workers before rethrowing the exception. New solver * Include more source location information when we hit an internal compiler error * Improve the logic that simplifies intersections of tables JIT * Save testable type annotations to bytecode * Improve block placement for linearized blocks * Add support for lea reg, [rip+offset] for labels * Unify X64 and A64 codegen for RETURN * Outline interrupt handlers for X64 * Remove global rArgN in favor of build.abi * Change A64 INTERRUPT lowering to match X64 --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
No description provided.