Skip to content
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

Merged
merged 4 commits into from
Jun 12, 2023

Conversation

JohnnyMorganz
Copy link
Contributor

No description provided.

@@ -1151,6 +1152,15 @@ ControlFlow ConstraintGraphBuilder::visit(const ScopePtr& scope, AstStatDeclareC

scope->exportedTypeBindings[className] = TypeFun{{}, classTy};

if (FFlag::LuauParseDeclareClassIndexer && declaredClass->indexer)
{
// TODO: Recursion limit.
Copy link
Collaborator

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.

Copy link
Contributor Author

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

Comment on lines +1159 to +1169
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),
};
}
Copy link
Contributor Author

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

@andyfriesen andyfriesen merged commit bc07224 into luau-lang:master Jun 12, 2023
@JohnnyMorganz JohnnyMorganz deleted the classtype-indexer branch June 12, 2023 21:41
andyfriesen added a commit that referenced this pull request Jun 16, 2023
* 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>
RomanKhafizianov added a commit to RomanKhafizianov/luau that referenced this pull request Nov 27, 2023
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants