-
Notifications
You must be signed in to change notification settings - Fork 46
Generics #786
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
base: main
Are you sure you want to change the base?
Generics #786
Conversation
Summary of ChangesHello @xuhuanzy, 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 addresses an enhancement in the handling of generic types within the code analysis system. The primary change involves refining how rest parameters are processed when their generic type is instantiated as a tuple. Previously, the system might not have correctly expanded the elements of such a tuple into individual parameters, potentially leading to incorrect type checking. The updated logic now ensures that these tuple types are properly unfolded, allowing for accurate validation of function calls against generic definitions that utilize tuple-instantiated rest parameters. Highlights
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
|
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 aims to improve handling of generic variadic parameters, particularly when they resolve to a tuple type. The implementation has a critical logic flaw that can lead to parameters being dropped during type instantiation, which I've provided a fix for. Additionally, the new test case has an inverted assertion that would cause it to fail on correct code. I've included a suggestion to correct the test's logic.
crates/emmylua_code_analysis/src/semantic/generic/instantiate_type_generic.rs
Show resolved
Hide resolved
Expand tuple types when encountering rest parameters (`...`) during generic instantiation close EmmyLuaLs#738
Hi @xuhuanzy, sorry to bother, I wondered if this PR was allowing to infer the content of generic types captured in parameter ? Something along the lines of ---@generic T
---@param future Future<T>
---@return T
---@async
function await(future)
return future:wait()
end
--- somewhere in uv coroutine context
local result = await fetchUser() --- Future<User>
--- ^ User Anyway I am so gratetful to start a lua project in this times where this project make it really close to type systems I am used to working with ! Really a great future for embedded scripting <3 |
@Aetherall This PR is not needed. It already supported capturing generic parameters before this PR. This PR provides advanced usage, such as conditional types, mapped types, etc. ![]() |
I must be using incorrect version or settings, thanks for the confirmation ! Mapped types will allow me to remove a really big chunk of annotations in my project ahah many thanks for this PR |
No description provided.