Skip to content

Re-check "members lost through a nil-subtracting generic in a loop" before filing it upstream #26

Closed as not planned

Description

@mareklangiewicz

Upstream candidate, from myvi ticket 06 (2026-09-02, measured on 0.25.1 only):

---@class Box
---@field w integer
---@return Box[]
local function grid() end

---@generic T
---@param a T
---@return T -?
local function chk(a) return a end

for i in ipairs(list) do
  print(chk(grid()[i]).w)     -- OK   (inline)
  local c = chk(grid()[i])
  print(c.w)                  -- undefined-field: w   <- the bug
end

The ticket's original premise ("generics can't subtract nil") turned out not to be a bug. This member loss is.

Next: run the repro on 0.25.1, upstream main and the installed fork. If upstream main still shows it, search for duplicates and prepare a draft for Marek. If the fork fixes it, note which commit. If neither shows it, close.

Activity

  1. mareklangiewicz commented on Nov 17, 2026

    @mareklangiewicz
    OwnerAuthor

    Re-checked 2026-11-17. Cannot reproduce on any build, including the original 0.25.1, so this won't be filed upstream.

    • The ticket's snippet is abbreviated: with no blank line between @class Box and @return Box[], the class attaches to grid. Current builds then report call-non-callable, which is an artifact of the snippet, not the bug. With blank lines added it is clean on 0.25.1, fork c6fd72f and upstream 2c400ee.
    • Real site: a scratch copy of myhypr with the ---@type my.Box workaround removed from my/feat/spread.lua:113, checked with myhypr's .emmyrc.json plus luagnd. No undefined-field at the site on 0.25.1 (35 other diagnostics, so it did run), the fork or upstream.
    • The control failing on 0.25.1 means today's code no longer triggers the September shape. Most likely luagnd's chk annotations changed since (the dual overload, 2026-09-02). So this proves the workaround is no longer needed. It does not prove an engine fix.

    Closing. Dropping the workaround in myhypr separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions