You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Upstream PR candidate: bare ? type literal lowers to nil (LuaLS T|?), fork 14c7537a #37
Part of #14. The fix is #12 (closed, with the full measurements); this issue tracks only whether and how it goes upstream.
Why it's a candidate
It's upstream's own regression: 0.25.1 lowered a bare ? literal to nil, and upstream 3474c99 ("refactor project") lost that arm. Every ---@field x T|? then reads as required. The fork fix is one arm in semantic_db/query.rs, plus deleting the fork-only text check in sub_type_call (42537ac).
Before a draft (AGENTS.md "Porting a fork fix upstream")
Branch off upstream main in a scratch worktree. Cherry-pick only the query.rs arm and the test. sub_type_call is fork-only (42537ac), so check what upstream main has in its place.
The test (test_union_with_bare_question_is_optional) fails on main's source and passes with the arm.
Corpus diff with upstream main as the base (fork numbers don't carry over), with --against a same-day 0.25.1 run.
gndx emmylua lint on the branch.
Duplicate search on upstream issues/PRs (T|?, |?, missing-fields optional).
Opening the draft (gh pr create --draft) is Marek's call.
Upstream branch prepared (2026-11-17), every checklist item done
Branchfix-bare-question-optional, worktree ~/code/rust/emmylua-analyzer-rust-worktrees/bareq, one commit 52142e59 on upstream main 41366714. Local only, not pushed; tracking is unset so it can't push to upstream by accident. Contents: the query.rs arm plus test_union_with_bare_question_is_optional. The commit message mentions no fork issues.
sub_type_call: upstream main has no L - R lowering at all (42537ac is fork-only, and LuaTypeBinaryOperator::Sub appears only in the parser). So the port needs no doc_types.rs change and T -? isn't involved. The earlier unverified belief is now checked.
Red/green: the test fails on main's source (integer|?: [MissingFields] "Missing required fields: x") and passes with the arm, run alone, 1 test. Full emmylua_code_analysis: 1911 passed. gndx emmylua lint passes, recorded on the commit.
Corpus:corpus diff up-41366714-1117 bareq-52142e59-1117 --against v0251-1117 → totals 58021 → 57890, 294 changed lines: 215 agree, 79 fork-only, 0 uncompared. The diff prints NOT COMPARABLE because 5 trees are refused, all the same on both sides: upstream main crashes on async.nvim, neotest, neovim-runtime and tuis.nvim in both builds, and mason.nvim is the excluded blowup.
The 79 fork-only lines: 77 are in obsidian.nvim, which spells optionals T|? throughout (442 annotation lines); the other two are diffview config.lua:338 and nui tree/init.lua:239. 55 of the 79 don't appear in the fork's #12 diff. Verified as a whole: I respelled every annotation |? in a copy of obsidian.nvim as |nil. Upstream main without the arm on that copy gives the same 1053 hits as the branch on the original (0 differing lines). Control: main on the original gives 1184. So on obsidian.nvim the arm is exactly upstream's own T|nil behaviour, and the new hits are existing upstream T|nil checks that the old unknown was hiding.
Example of what it uncovers, and a possible separate finding. This fires on upstream main (4136671 and 2c400ee) with the field spelled string|nil, with or without the arm. It's clean on the fork (14c7537) and on 0.25.1:
---@classOpts---@fieldtitlestring|nil---@paramastring?localfunctionf3(a) returnaend---@paramoptsOpts|nillocalfunctiong(opts)
opts=optsor {}
f3(opts.title) -- upstream main: param-type-mismatch "expected `string?` but found `nil`"endreturng
Ran with emmylua_check . and .emmyrc.json = {}. An upstream reviewer running the PR on T|? code will see these new hits. The PR body should explain them as "T|? now equals T|nil" so they don't read as regressions.
Opened as upstream EmmyLuaLs#1421 (draft), 2026-11-17, from marek/fix-bare-question-optional @ 52142e5. The body has the before/after test, the corpus numbers and the |? → |nil equivalence. No fork issue numbers in it. Marking it ready is Marek's call. Row added to #14. Leaving this open until upstream merges or closes it.
Upstream closed 1421 (2026-11-17, "Should have been fixed"): re-measured on upstream main fcc0416 (2026-11-18)
Upstream reworked semantic_db/query.rs itself between 4136671 and fcc0416 (76c776b, b38ed6f "preserve nil for optional fields in member type queries", 991b3eb, 2985e88), so 1421's arm no longer applies there. Upstream main has no Question → nil mapping. The only Question arms left (facts.rs:730, flow/stats.rs:195) map it to None.
gndx emmylua probe with .emmyrc.json = {} (bin1 = old main 4136671):
---@classA---@fieldxinteger|?---@fieldyinteger|?|nil---@fieldzinteger?|?---@typeAlocala= {} -- line 7---@paramninteger|?localfunctionf(n) returnnendf() -- line 11
plus controls ---@field w integer (line 16) and ---@param m integer (line 20).
Fields: fixed upstream.integer|? fields are optional again on fcc0416.
Params: still broken upstream.---@param n integer|? is still a required parameter on fcc0416, while 0.25.1 and the fork treat it as optional. This is the case 06fc02b added to 1421. The maintainer's "should have been fixed" covers the field half only.
Next is Marek's call: tell upstream about the param half (a reply on 1421 or a new issue with the 7-line repro above), or leave it. The fork's arm stays either way until a merge brings in the reworked query.rs.
Posted the @param half upstream as plain-text "upstream EmmyLuaLs#1425" (2026-11-18): repro, four-build table, cause (bare ? still hits _ => TypeShell::unknown() in query.rs on fcc0416), and verified that 1421's arm cherry-picked onto fcc0416 (build ref-994ddc30) fixes it. Offered to reopen 1421 or open a fresh PR. Waiting on upstream.
Branchfix-bare-question-optional in worktree bareq, rebased cleanly onto 70dbcf4: 468d38ca (the query.rs arm) + 83559d96 (tests). It is not pushed, so marek/fix-bare-question-optional still points at 06fc02b.
Red/green (gndx emmylua test bareq --filter=… --red-revert=468d38ca): test_param_union_with_bare_question_is_optional fails with the arm reverted and passes with it. test_union_with_bare_question_is_optional (fields) passes either way, since upstream fixed the field half. It stays as a guard. Full suite: 1983 passed. Lint passes.
Corpus corpus diff up-70dbcf4d-1120 bareq-83559d96-1120 --against v0251-1120: 57387 → 57276, 257 changed lines, 186 agree with 0.25.1, 71 differ (65 in obsidian.nvim). "NOT COMPARABLE" only because the same trees are refused on both sides (crashes on upstream: async.nvim, bufferline.nvim, neotest, neovim-runtime, tuis.nvim; mason.nvim excluded).
Lowering control: obsidian.nvim copied with every annotation |? respelled |nil. Upstream on the copy gives 1027, the branch on the original gives 1027, and upstream on the original (control) gives 1137. On obsidian the arm is exactly upstream's own T|nil behaviour.
Next is Marek's call: push the rebased branch and reopen 1421 or open a fresh draft PR, or keep waiting on EmmyLuaLs#1425.
Upstream 1421 can't be reopened by its author (a maintainer closed it), so the param half went up as a fresh draft: upstream EmmyLuaLs#1445 (2026-11-20), from marek/fix-bare-question-optional. The branch was force-pushed with two commits on 70dbcf4: 5aa3687 (the arm + test_param_union_with_bare_question_is_optional, red → green with --red-revert=5aa36874) and 0e3703e (field spellings as guard tests). The code comment no longer mentions T -?, which upstream doesn't lower. The body has the 70dbcf4 corpus numbers and the obsidian control from the comment above, and it links upstream EmmyLuaLs#1425 and 1421. Marking it ready is Marek's call. Row updated in #14.
Upstream 1445 merged 2026-11-23 (upstream commit 53c20d3, merged by CppCXY): bare ? lowers to nil upstream, so ---@param n integer|? is optional (upstream issue 1425). The fork's own version (14c7537) meets upstream's 5aa3687 on the next gndx emmylua sync.
Activity
mareklangiewicz commentedon Nov 17, 2026
Upstream branch prepared (2026-11-17), every checklist item done
Branch
fix-bare-question-optional, worktree~/code/rust/emmylua-analyzer-rust-worktrees/bareq, one commit52142e59on upstream main41366714. Local only, not pushed; tracking is unset so it can't push to upstream by accident. Contents: thequery.rsarm plustest_union_with_bare_question_is_optional. The commit message mentions no fork issues.sub_type_call: upstream main has noL - Rlowering at all (42537ac is fork-only, andLuaTypeBinaryOperator::Subappears only in the parser). So the port needs nodoc_types.rschange andT -?isn't involved. The earlier unverified belief is now checked.Red/green: the test fails on main's source (
integer|?: [MissingFields] "Missing required fields: x") and passes with the arm, run alone, 1 test. Fullemmylua_code_analysis: 1911 passed.gndx emmylua lintpasses, recorded on the commit.Corpus:
corpus diff up-41366714-1117 bareq-52142e59-1117 --against v0251-1117→ totals 58021 → 57890, 294 changed lines: 215 agree, 79 fork-only, 0 uncompared. The diff prints NOT COMPARABLE because 5 trees are refused, all the same on both sides: upstream main crashes on async.nvim, neotest, neovim-runtime and tuis.nvim in both builds, and mason.nvim is the excluded blowup.The 79 fork-only lines: 77 are in obsidian.nvim, which spells optionals
T|?throughout (442 annotation lines); the other two are diffview config.lua:338 and nui tree/init.lua:239. 55 of the 79 don't appear in the fork's #12 diff. Verified as a whole: I respelled every annotation|?in a copy of obsidian.nvim as|nil. Upstream main without the arm on that copy gives the same 1053 hits as the branch on the original (0 differing lines). Control: main on the original gives 1184. So on obsidian.nvim the arm is exactly upstream's ownT|nilbehaviour, and the new hits are existing upstreamT|nilchecks that the oldunknownwas hiding.Example of what it uncovers, and a possible separate finding. This fires on upstream main (4136671 and 2c400ee) with the field spelled
string|nil, with or without the arm. It's clean on the fork (14c7537) and on 0.25.1:Ran with
emmylua_check .and.emmyrc.json={}. An upstream reviewer running the PR onT|?code will see these new hits. The PR body should explain them as "T|?now equalsT|nil" so they don't read as regressions.Opening the draft is Marek's call.
AGENTS.md: porting upstream: respell test for lowering fixes; duplica…
mareklangiewicz commentedon Nov 17, 2026
Opened as upstream EmmyLuaLs#1421 (draft), 2026-11-17, from
marek/fix-bare-question-optional@ 52142e5. The body has the before/after test, the corpus numbers and the|?→|nilequivalence. No fork issue numbers in it. Marking it ready is Marek's call. Row added to #14. Leaving this open until upstream merges or closes it.mareklangiewicz commentedon Nov 17, 2026
Upstream closed 1421 (2026-11-17, "Should have been fixed"): re-measured on upstream main fcc0416 (2026-11-18)
Upstream reworked
semantic_db/query.rsitself between 4136671 and fcc0416 (76c776b, b38ed6f "preserve nil for optional fields in member type queries", 991b3eb, 2985e88), so 1421's arm no longer applies there. Upstream main has noQuestion→ nil mapping. The onlyQuestionarms left (facts.rs:730,flow/stats.rs:195) map it toNone.gndx emmylua probewith.emmyrc.json={}(bin1 = old main 4136671):plus controls
---@field w integer(line 16) and---@param m integer(line 20).xinteger|?param)w(control)m(control)integer|?fields are optional again on fcc0416.---@param n integer|?is still a required parameter on fcc0416, while 0.25.1 and the fork treat it as optional. This is the case 06fc02b added to 1421. The maintainer's "should have been fixed" covers the field half only.Next is Marek's call: tell upstream about the param half (a reply on 1421 or a new issue with the 7-line repro above), or leave it. The fork's arm stays either way until a merge brings in the reworked
query.rs.mareklangiewicz commentedon Nov 17, 2026
Posted the
@paramhalf upstream as plain-text "upstream EmmyLuaLs#1425" (2026-11-18): repro, four-build table, cause (bare?still hits_ => TypeShell::unknown()inquery.rson fcc0416), and verified that 1421's arm cherry-picked onto fcc0416 (buildref-994ddc30) fixes it. Offered to reopen 1421 or open a fresh PR. Waiting on upstream.mareklangiewicz commentedon Nov 20, 2026
Re-measured on upstream main 70dbcf4 (2026-11-20); branch rebased, local only
upstream EmmyLuaLs#1425 has no reply yet. The
@paramhalf is still broken on 70dbcf4 (gndx emmylua probe,{}config):f()with---@param n integer|?: missing-parameterwfield,mparam)Branch
fix-bare-question-optionalin worktreebareq, rebased cleanly onto 70dbcf4: 468d38ca (thequery.rsarm) + 83559d96 (tests). It is not pushed, somarek/fix-bare-question-optionalstill points at 06fc02b.gndx emmylua test bareq --filter=… --red-revert=468d38ca):test_param_union_with_bare_question_is_optionalfails with the arm reverted and passes with it.test_union_with_bare_question_is_optional(fields) passes either way, since upstream fixed the field half. It stays as a guard. Full suite: 1983 passed. Lint passes.corpus diff up-70dbcf4d-1120 bareq-83559d96-1120 --against v0251-1120: 57387 → 57276, 257 changed lines, 186 agree with 0.25.1, 71 differ (65 in obsidian.nvim). "NOT COMPARABLE" only because the same trees are refused on both sides (crashes on upstream: async.nvim, bufferline.nvim, neotest, neovim-runtime, tuis.nvim; mason.nvim excluded).|?respelled|nil. Upstream on the copy gives 1027, the branch on the original gives 1027, and upstream on the original (control) gives 1137. On obsidian the arm is exactly upstream's ownT|nilbehaviour.Next is Marek's call: push the rebased branch and reopen 1421 or open a fresh draft PR, or keep waiting on EmmyLuaLs#1425.
mareklangiewicz commentedon Nov 20, 2026
Upstream 1421 can't be reopened by its author (a maintainer closed it), so the param half went up as a fresh draft: upstream EmmyLuaLs#1445 (2026-11-20), from
marek/fix-bare-question-optional. The branch was force-pushed with two commits on 70dbcf4: 5aa3687 (the arm +test_param_union_with_bare_question_is_optional, red → green with--red-revert=5aa36874) and 0e3703e (field spellings as guard tests). The code comment no longer mentionsT -?, which upstream doesn't lower. The body has the 70dbcf4 corpus numbers and the obsidian control from the comment above, and it links upstream EmmyLuaLs#1425 and 1421. Marking it ready is Marek's call. Row updated in #14.mareklangiewicz commentedon Nov 20, 2026
Upstream PR 1445 marked ready for review 2026-11-20 (all CI green; the bot review was answered in 8e4f67e).
mareklangiewicz commentedon Nov 23, 2026
Upstream 1445 merged 2026-11-23 (upstream commit 53c20d3, merged by CppCXY): bare
?lowers to nil upstream, so---@param n integer|?is optional (upstream issue 1425). The fork's own version (14c7537) meets upstream's 5aa3687 on the nextgndx emmylua sync.