Result of `table.pack` is of a union instead of an intersection type

Open Beginner friendly
#1,016 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
lua
Domain
tooling

Research direction

Start in crates/emmylua_code_analysis/resources/std/table.lua at line 122 and inspect the return annotation for table.pack. Update the annotation so the packed tuple and the { n: integer } field are represented as an intersection, then verify that conditional index accesses no longer produce the reported type-checker complaint.

Written by the indexing model from the issue text.

Description

Currently, the type-checker complains about index accesses of a table.pack result inside condition branches that check that field n is not nil.

https://github.com/EmmyLuaLs/emmylua-analyzer-rust/blob/381d67737fd068a9056572716461219d28aa9c23/crates/emmylua_code_analysis/resources/std/table.lua#L122
should be instead:

---@return [T...] & { n: integer }
Dominant language
Rust
Stars
507
Forks
94
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from EmmyLuaLs/emmylua-analyzer-rust

All issues in EmmyLuaLs/emmylua-analyzer-rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.