-
Notifications
You must be signed in to change notification settings - Fork 57
fix(typecheck): accept intersections in class assignments #947
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
Conversation
lewis6991
commented
Feb 4, 2026
- allow intersection types to be checked against class refs
- add tests for intersection<->class assignment behavior
- update intersection docs (EN/CN) and overload docs
- keep annotation tests aligned with intersection semantics
Summary of ChangesHello @lewis6991, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the type analysis capabilities by enabling the type checker to properly handle assignments involving intersection types and class definitions. It ensures that complex type compositions, where properties from multiple types are merged, are correctly validated against class structures, leading to more robust and accurate type inference. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
894b1a3 to
a78b84a
Compare
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.
Code Review
This pull request successfully implements type checking for assignments involving intersection types and class references. The changes are well-supported by new tests that cover various scenarios, including property overwriting based on intersection order. The documentation for intersection types has also been updated in both English and Chinese, which is a great addition for users. The core logic changes in intersection_type_check.rs and ref_type.rs correctly handle the conversion of intersection types to object types for comparison. I have one suggestion to improve code style for consistency. Overall, this is a great enhancement.
| if let Some(object_type) = intersection_to_object(context.db, source_intersection) { | ||
| let object_type = LuaType::Object(Arc::new(object_type)); | ||
| return check_general_type_compact( | ||
| context, | ||
| &object_type, | ||
| compact_type, | ||
| check_guard.next_level()?, | ||
| ); | ||
| } | ||
| Err(TypeCheckFailReason::TypeNotMatch) |
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.
For better readability and consistency with idiomatic Rust, you can refactor this if block to be an expression. This avoids the explicit return and makes the code flow similar to the new logic in ref_type.rs.
if let Some(object_type) = intersection_to_object(context.db, source_intersection) {
let object_type = LuaType::Object(Arc::new(object_type));
check_general_type_compact(
context,
&object_type,
compact_type,
check_guard.next_level()?,
)
} else {
Err(TypeCheckFailReason::TypeNotMatch)
}|
You should install the Git hooks first. The hooks include some basic checks to prevent failures in basic GitHub Actions checks. Also, regarding AI usage, I recommend using |
|
Ah ok, I have been using |
a78b84a to
e6c3d4e
Compare
|
|
|
You can use From what I’ve seen, code generated by |
|
The previous PR already handles some pretty whacky edge cases (with tests). I can try though. |
e32ebd4 to
7754eef
Compare
- allow intersection types to be checked against class refs - include inherited class members when checking intersection-derived objects against class refs - add regression tests for intersection<->class assignment and table literal behavior - update intersection docs (EN/CN) and overload docs - keep annotation tests aligned with intersection semantics
7754eef to
db14bb1
Compare