fix(type): preserve unknown unions and narrow pcall(any)#997
Open
lewis6991 wants to merge 1 commit intoEmmyLuaLs:mainfrom
Open
fix(type): preserve unknown unions and narrow pcall(any)#997lewis6991 wants to merge 1 commit intoEmmyLuaLs:mainfrom
lewis6991 wants to merge 1 commit intoEmmyLuaLs:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request improves the handling of never types within unions and simplifies the processing of MultiLineUnion types across the codebase. Specifically, LuaType::from_vec now correctly preserves LuaType::Never when a union would otherwise be empty, and several semantic analysis functions were refactored to recursively handle the results of MultiLineUnion::to_union. Additionally, new test cases were added to verify type preservation for multiline aliases and type narrowing with pcall. I have no feedback to provide.
6e67f2c to
553df12
Compare
553df12 to
dde00cd
Compare
dde00cd to
23f70d7
Compare
Preserve unknown as a real union member in type unions and doc-type parsing instead of collapsing unknown|T to T. Update call sites that previously used Unknown as an empty union accumulator to use Never or explicit first-value handling, and avoid merging missing closure param annotations as unknown. Keep the pcall(any) flow fixes so the payload stays unknown|string outside the branch, narrows to unknown on success, and narrows to string on failure.
23f70d7 to
ccab61c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preserve unknown as a real union member in type unions and doc-type
parsing instead of collapsing unknown|T to T.
Update call sites that previously used Unknown as an empty union
accumulator to use Never or explicit first-value handling, and avoid
merging missing closure param annotations as unknown.
Keep the pcall(any) flow fixes so the payload stays unknown|string
outside the branch, narrows to unknown on success, and narrows to string
on failure.
This fixes local ok, result = pcall(x) where x:any so the success branch
sees unknown and the failure branch sees string.