WIP: test(vk): the brace check holds vk_internal.h's mkwvk functions inside mkwvk, compares each #if's branches and reads only tracked files #1960

Draft
d4nkn3ss wants to merge 1 commit from d4nkn3ss/Longshot:fix/vk-braces-scope into main
Contributor

Summary

tests/test_vk_braces.py came in with #1949 (main's build break: a stray brace closed namespace mkwvk early in vk_replay.cpp). BeanBot's review of #1949 found four gaps in it, and #1949 merged before they were answered. This answers them:

  • The scope, not only the count. Balanced braces pass when the namespace's close is moved up to just after present_thread_drain(), which leaves swapchain_made_ready() outside mkwvk and breaks the build the same way. Now every function vk_internal.h declares in namespace mkwvk (203 of them) must be defined inside it, by name, in each gpu/vk source that defines it.
  • The other platform's branches. It followed only the first branch of each #if, so an extra brace in a Linux #else passed. Now every branch of an #if must change the depth as the first does (the namespaces still follow the first).
  • Directives in comments. Comments and literals are now taken out before preprocessor lines are read, so an #if 0 inside a block comment no longer hides real code. A // comment continued by a backslash runs on to the next line, as C++ joins them.
  • What it reads. It reads git's tracked files under gpu/vk (or the tree when git can't say), never a symlink or a path outside the checkout, so a scratch header doesn't fail the suite.
  • The unused depth_skip is gone.

On main: move vk_replay.cpp's last } // namespace mkwvk to just after present_thread_drain() (the build breaks) and run python -I -B tests/test_vk_braces.py: it passes.

Read first: Scan (its directive and char) and blank() in tests/test_vk_braces.py.

See #1949.

Testing

Tested:

  • python -I -B tests/test_vk_braces.py: passes on main @ 00e0dc93 (548 sources, 203 functions). The same on Linux (Debian under WSL 2, Python 3), and through tests/run_all.py.
  • Each review case, edited into a copy of vk_replay.cpp (or a file added) and put back:
case main's check this check
#1105's stray brace after present_thread_drain() fails fails: line 7785: a '}' with nothing open
the namespace's close moved to just after present_thread_drain() passes fails: line 6559: swapchain_made_ready() is defined outside namespace mkwvk
an extra } in the Linux #else of the acquire timeout passes fails: line 5942: the last branch of the #if at line 5932 changes the depth by -1, its first by +0
a block comment showing #ifdef X / #else (no #endif) fails (wrongly: 1 brace(s) left open at the end, the comment's own */ blanked) passes
a // comment ending in a backslash, a } on the next line fails (wrongly) passes
an untracked gpu/vk/zz_scratch.h holding } fails passes
  • Only tests/test_vk_braces.py changes, and no other check reads it. The rest of the suite runs as on main (mise isn't installed here; checks through tests/run_all.py).

Still to test: None

Measurements

Nothing to measure: a check only. It takes about 7 s through run_all on this PC.

Risks

None for players: only a check changes. Two separate #ifdef X and #ifndef X blocks that each open a brace would both be counted and fail it. None exists now, and the failure names the line.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary `tests/test_vk_braces.py` came in with #1949 (main's build break: a stray brace closed `namespace mkwvk` early in `vk_replay.cpp`). BeanBot's review of #1949 found four gaps in it, and #1949 merged before they were answered. This answers them: - **The scope, not only the count.** Balanced braces pass when the namespace's close is moved up to just after `present_thread_drain()`, which leaves `swapchain_made_ready()` outside `mkwvk` and breaks the build the same way. Now every function `vk_internal.h` declares in `namespace mkwvk` (203 of them) must be defined inside it, by name, in each `gpu/vk` source that defines it. - **The other platform's branches.** It followed only the first branch of each `#if`, so an extra brace in a Linux `#else` passed. Now every branch of an `#if` must change the depth as the first does (the namespaces still follow the first). - **Directives in comments.** Comments and literals are now taken out before preprocessor lines are read, so an `#if 0` inside a block comment no longer hides real code. A `//` comment continued by a backslash runs on to the next line, as C++ joins them. - **What it reads.** It reads git's tracked files under `gpu/vk` (or the tree when git can't say), never a symlink or a path outside the checkout, so a scratch header doesn't fail the suite. - The unused `depth_skip` is gone. **On main:** move `vk_replay.cpp`'s last `} // namespace mkwvk` to just after `present_thread_drain()` (the build breaks) and run `python -I -B tests/test_vk_braces.py`: it passes. Read first: `Scan` (its `directive` and `char`) and `blank()` in `tests/test_vk_braces.py`. See #1949. ## Testing **Tested:** - `python -I -B tests/test_vk_braces.py`: passes on main @ 00e0dc93 (548 sources, 203 functions). The same on Linux (Debian under WSL 2, Python 3), and through `tests/run_all.py`. - Each review case, edited into a copy of `vk_replay.cpp` (or a file added) and put back: | case | main's check | this check | |---|---|---| | #1105's stray brace after `present_thread_drain()` | fails | fails: `line 7785: a '}' with nothing open` | | the namespace's close moved to just after `present_thread_drain()` | passes | fails: `line 6559: swapchain_made_ready() is defined outside namespace mkwvk` | | an extra `}` in the Linux `#else` of the acquire timeout | passes | fails: `line 5942: the last branch of the #if at line 5932 changes the depth by -1, its first by +0` | | a block comment showing `#ifdef X` / `#else` (no `#endif`) | fails (wrongly: `1 brace(s) left open at the end`, the comment's own `*/` blanked) | passes | | a `//` comment ending in a backslash, a `}` on the next line | fails (wrongly) | passes | | an untracked `gpu/vk/zz_scratch.h` holding `}` | fails | passes | - Only `tests/test_vk_braces.py` changes, and no other check reads it. The rest of the suite runs as on main (`mise` isn't installed here; checks through `tests/run_all.py`). **Still to test:** None ## Measurements Nothing to measure: a check only. It takes about 7 s through `run_all` on this PC. ## Risks None for players: only a check changes. Two separate `#ifdef X` and `#ifndef X` blocks that each open a brace would both be counted and fail it. None exists now, and the failure names the line. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
test(vk): the brace check holds vk_internal.h's mkwvk functions inside mkwvk, compares each #if's branches and reads only tracked files
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 6s
67024c233f
From the review of #1949. Balanced braces alone pass when the namespace's close is moved up (swapchain_made_ready() then
outside it); now every function vk_internal.h declares in namespace mkwvk must be defined inside it. Comments and
literals are taken out before preprocessor lines are read (an #if 0 in a comment, a // comment continued by a
backslash), and every branch of an #if must change the depth as its first does, so the Linux arms are checked too. The
files are git's tracked ones under gpu/vk, never a symlink or a path outside the checkout.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
BeanBot left a comment

Recommendation: Request changes. The check catches the reported vk_replay.cpp regression, but it already misses a declaration in vk_internal.h and can pass a broken Linux branch. File selection can also scan the wrong tree, and the new per-character scanner adds avoidable work to every full suite run.

This gives contributors an earlier, game-free warning when a renderer function moves outside its namespace or a platform branch adds an unmatched brace. The reported examples show the benefit. Incomplete parsing and file selection can still miss build breaks or fail a valid checkout.

Does it help: Yes for the cases shown. The PR's comparison against 00e0dc93 reports five improved outcomes: the balanced namespace move and the extra Linux brace now fail, while the block comment, continued line comment, and scratch header cases now pass. The original stray brace fails on both. The reported scan of 548 files and 203 names does not establish complete declaration coverage. The reported roughly 7 seconds through run_all.py has no paired base timing.
Other systems: The diff changes one game-free Python check auto-discovered by tests/run_all.py and used by Forgejo and CircleCI. It can affect CI time and what contributors catch before building on Windows or Linux, including Steam Deck. It changes no game runtime, GPU path, player build step, save, audio, input, cache, or launcher behavior.
Switches: None.

Reviewed: 67024c233f against 00e0dc93a9: Read the full base-to-HEAD diff, tests/test_vk_braces.py in full twice, the commit and trailers, AGENTS.md, CONTRIBUTING.md, the Forgejo template, and docs/dev/standards.md. No review checklist file was present. Read the relevant suite discovery and subprocess code, vk_internal.h declarations, and the affected scope and call sites in vk_replay.cpp, vk_vma.cpp, vk_main.cpp, and vk_texture.cpp. Skimmed CI configuration, the #1949 record, the current PR's results, generated shader headers, and translations. The remainder of the renderer and test runner was outside the read.; nothing run (a code review).
Checked and fine:

  • The commit is one topic, uses a Conventional Commit title, and carries both AI assistance trailers.
  • The diff contains no game-derived data, generated output, third-party changes, or renderer API changes.
  • The check is standard-library Python and needs no compiler or Vulkan device. Its only new subprocess is the described read-only git ls-files.
  • The NUL-delimited Git listing preserves spaces and non-ASCII UTF-8 path names. The ordinary tracked-file path excludes the reported untracked scratch header.

Blocking (to change before merge)

  1. tests/test_vk_braces.py:131: The scanner loses a real declaration when a parameter default contains braces. vk_internal.h declares destroy_image_later with views = {} and memory = {}. The first { resets the pending declaration, so ours never contains this name. Moving its definition in vk_vma.cpp outside mkwvk would escape the new check. Keep balanced default expressions inside the function declarator until its closing ) and cover this signature in a fixture.
  2. tests/test_vk_braces.py:157: Scope membership is tested by the presence of the string mkwvk. A swapchain_made_ready() definition inside a nested namespace detail { ... } within mkwvk passes even though it defines mkwvk::detail::swapchain_made_ready. The bare-name lookup also rejects an independent helper such as a file-local compile_all(int). Track the full namespace and distinguish the declared function from unrelated overloads.
  3. tests/test_vk_braces.py:129: Equal final depth can hide underflow in a non-first branch. At file scope, an empty Windows arm and a Linux arm containing } followed by namespace mkwvk { both have net depth zero. The scanner passes while Linux sees a stray close. Check each arm from the depth at conditional entry, including the lowest depth it reaches.
  4. tests/test_vk_braces.py:117: A conditional with no #else omits the implicit empty arm. Putting the final vk_replay.cpp namespace close under #ifdef _WIN32 passes the check while Linux ends with the namespace open. Compare against a zero-delta arm when the conditional can select no explicit branch.
  5. tests/test_vk_braces.py:130: Alternate arms never get a scope check, yet their text can overwrite the function head used by the first arm. At file scope, put bool swapchain_made_ready() in the Windows arm and bool unrelated() in the Linux arm, with the body after #endif. The regex picks unrelated and misses the misplaced Windows definition. Keep branch-local scope and pending declarator state from #if, and check each branch through any shared function head or body.
  6. tests/test_vk_braces.py:46: Line splicing is only handled after some tokens have already been recognized. A / followed by a backslash-newline and then / } forms a line comment in C++, but this scanner counts its }. A splice inside #else can likewise hide the branch boundary. Recognize splices before tokenizing comments, ordinary literals, and directives, while mapping diagnostics back to physical lines and preserving raw-string contents.
  7. tests/test_vk_braces.py:163: cwd=ROOT still lets Git inherit GIT_INDEX_FILE, GIT_DIR, and GIT_WORK_TREE. An alternate staging index that includes gpu/vk/zz_scratch.h can therefore fail the check the PR says it fixes. A source archive unpacked under another Git worktree can also get an empty successful listing and miss the tree fallback. Clear Git's repository and index overrides, verify the discovered root, and report listing errors in a recognized checkout.
  8. tests/test_vk_braces.py:170: Only the final component is checked for symlinks. If a tracked directory such as gpu/vk/eden is replaced locally with a symlink to an in-tree scratch copy, its files pass both filters and are scanned. Check every component below the checkout root and prune symlinked directories and Windows junctions before walking the fallback tree.
  9. tests/test_vk_braces.py:125: Appending each character to self.code repeatedly copies the pending string on CPython, even inside scopes where the function recognizer immediately returns. The tracked ASTC shader header alone puts about 359 KB in one initializer. Buffer tokens or chunks and keep function-head text only where it can affect a scope decision.
  10. tests/test_vk_braces.py:178: The regressions were exercised by hand only. A future edit could remove the namespace comparison or alternate-arm validation and the clean tree would still pass. Add small game-free fixtures that assert the reported failures and successes, including temporary trees for tracked-file and symlink selection.

Waiting on the author (a run, a measurement or a decision; no edit does it)

  • tests/test_vk_braces.py: After removing the repeated copying, report paired timings for the brace check on the base and updated head using the same checkout contents and Python. The reported roughly 7 seconds gives no base comparison for the cost added to CI and local checks.
  • The description ticks the strict suite box but names run_all.py without its flags or results. Report the updated head's run_all.py --strict results and any matching base failures, and identify which scanner and file-selection cases ran under native Windows and Linux.

Testing: Read-only review. No project code, builds, or tests were run. The author's mutation table is the available evidence for this PR. The Windows and Linux results recorded in #1949 apply to the earlier check. No head CI result was supplied.
Overlaps and merge order: #1949 introduced the check and is already in the base. No other overlap was found in the checkout or supplied discussion.


Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The check catches the reported `vk_replay.cpp` regression, but it already misses a declaration in `vk_internal.h` and can pass a broken Linux branch. File selection can also scan the wrong tree, and the new per-character scanner adds avoidable work to every full suite run. This gives contributors an earlier, game-free warning when a renderer function moves outside its namespace or a platform branch adds an unmatched brace. The reported examples show the benefit. Incomplete parsing and file selection can still miss build breaks or fail a valid checkout. **Does it help:** Yes for the cases shown. The PR's comparison against `00e0dc93` reports five improved outcomes: the balanced namespace move and the extra Linux brace now fail, while the block comment, continued line comment, and scratch header cases now pass. The original stray brace fails on both. The reported scan of 548 files and 203 names does not establish complete declaration coverage. The reported roughly 7 seconds through `run_all.py` has no paired base timing. **Other systems:** The diff changes one game-free Python check auto-discovered by `tests/run_all.py` and used by Forgejo and CircleCI. It can affect CI time and what contributors catch before building on Windows or Linux, including Steam Deck. It changes no game runtime, GPU path, player build step, save, audio, input, cache, or launcher behavior. **Switches:** None. **Reviewed:** 67024c233fa1 against 00e0dc93a9f8: Read the full base-to-HEAD diff, `tests/test_vk_braces.py` in full twice, the commit and trailers, `AGENTS.md`, `CONTRIBUTING.md`, the Forgejo template, and `docs/dev/standards.md`. No review checklist file was present. Read the relevant suite discovery and subprocess code, `vk_internal.h` declarations, and the affected scope and call sites in `vk_replay.cpp`, `vk_vma.cpp`, `vk_main.cpp`, and `vk_texture.cpp`. Skimmed CI configuration, the #1949 record, the current PR's results, generated shader headers, and translations. The remainder of the renderer and test runner was outside the read.; nothing run (a code review). **Checked and fine:** - The commit is one topic, uses a Conventional Commit title, and carries both AI assistance trailers. - The diff contains no game-derived data, generated output, third-party changes, or renderer API changes. - The check is standard-library Python and needs no compiler or Vulkan device. Its only new subprocess is the described read-only `git ls-files`. - The NUL-delimited Git listing preserves spaces and non-ASCII UTF-8 path names. The ordinary tracked-file path excludes the reported untracked scratch header. **Blocking** (to change before merge) 1. tests/test_vk_braces.py:131: The scanner loses a real declaration when a parameter default contains braces. `vk_internal.h` declares `destroy_image_later` with `views = {}` and `memory = {}`. The first `{` resets the pending declaration, so `ours` never contains this name. Moving its definition in `vk_vma.cpp` outside `mkwvk` would escape the new check. Keep balanced default expressions inside the function declarator until its closing `)` and cover this signature in a fixture. 2. tests/test_vk_braces.py:157: Scope membership is tested by the presence of the string `mkwvk`. A `swapchain_made_ready()` definition inside a nested `namespace detail { ... }` within `mkwvk` passes even though it defines `mkwvk::detail::swapchain_made_ready`. The bare-name lookup also rejects an independent helper such as a file-local `compile_all(int)`. Track the full namespace and distinguish the declared function from unrelated overloads. 3. tests/test_vk_braces.py:129: Equal final depth can hide underflow in a non-first branch. At file scope, an empty Windows arm and a Linux arm containing `}` followed by `namespace mkwvk {` both have net depth zero. The scanner passes while Linux sees a stray close. Check each arm from the depth at conditional entry, including the lowest depth it reaches. 4. tests/test_vk_braces.py:117: A conditional with no `#else` omits the implicit empty arm. Putting the final `vk_replay.cpp` namespace close under `#ifdef _WIN32` passes the check while Linux ends with the namespace open. Compare against a zero-delta arm when the conditional can select no explicit branch. 5. tests/test_vk_braces.py:130: Alternate arms never get a scope check, yet their text can overwrite the function head used by the first arm. At file scope, put `bool swapchain_made_ready()` in the Windows arm and `bool unrelated()` in the Linux arm, with the body after `#endif`. The regex picks `unrelated` and misses the misplaced Windows definition. Keep branch-local scope and pending declarator state from `#if`, and check each branch through any shared function head or body. 6. tests/test_vk_braces.py:46: Line splicing is only handled after some tokens have already been recognized. A `/` followed by a backslash-newline and then `/ }` forms a line comment in C++, but this scanner counts its `}`. A splice inside `#else` can likewise hide the branch boundary. Recognize splices before tokenizing comments, ordinary literals, and directives, while mapping diagnostics back to physical lines and preserving raw-string contents. 7. tests/test_vk_braces.py:163: `cwd=ROOT` still lets Git inherit `GIT_INDEX_FILE`, `GIT_DIR`, and `GIT_WORK_TREE`. An alternate staging index that includes `gpu/vk/zz_scratch.h` can therefore fail the check the PR says it fixes. A source archive unpacked under another Git worktree can also get an empty successful listing and miss the tree fallback. Clear Git's repository and index overrides, verify the discovered root, and report listing errors in a recognized checkout. 8. tests/test_vk_braces.py:170: Only the final component is checked for symlinks. If a tracked directory such as `gpu/vk/eden` is replaced locally with a symlink to an in-tree scratch copy, its files pass both filters and are scanned. Check every component below the checkout root and prune symlinked directories and Windows junctions before walking the fallback tree. 9. tests/test_vk_braces.py:125: Appending each character to `self.code` repeatedly copies the pending string on CPython, even inside scopes where the function recognizer immediately returns. The tracked ASTC shader header alone puts about 359 KB in one initializer. Buffer tokens or chunks and keep function-head text only where it can affect a scope decision. 10. tests/test_vk_braces.py:178: The regressions were exercised by hand only. A future edit could remove the namespace comparison or alternate-arm validation and the clean tree would still pass. Add small game-free fixtures that assert the reported failures and successes, including temporary trees for tracked-file and symlink selection. **Waiting on the author** (a run, a measurement or a decision; no edit does it) - tests/test_vk_braces.py: After removing the repeated copying, report paired timings for the brace check on the base and updated head using the same checkout contents and Python. The reported roughly 7 seconds gives no base comparison for the cost added to CI and local checks. - The description ticks the strict suite box but names `run_all.py` without its flags or results. Report the updated head's `run_all.py --strict` results and any matching base failures, and identify which scanner and file-selection cases ran under native Windows and Linux. **Testing:** Read-only review. No project code, builds, or tests were run. The author's mutation table is the available evidence for this PR. The Windows and Linux results recorded in #1949 apply to the earlier check. No head CI result was supplied. **Overlaps and merge order:** #1949 introduced the check and is already in the base. No other overlap was found in the checkout or supplied discussion. --- <sub>Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -63,3 +46,1 @@
elif src.startswith("//", i):
i = src.find("\n", i)
i = n if i < 0 else i
if src.startswith("//", i):
Member

A backslash-newline can join two slashes into a comment or join pieces of a directive. Recognize splices before lexing and retain physical line numbers.

A backslash-newline can join two slashes into a comment or join pieces of a directive. Recognize splices before lexing and retain physical line numbers.
@ -101,3 +175,4 @@
return sorted(keep)
def main():
Member

Keep the mutation cases as executable fixtures. The clean-tree run alone cannot tell if the new rejection rules are removed.

Keep the mutation cases as executable fixtures. The clean-tree run alone cannot tell if the new rejection rules are removed.
@ -101,0 +114,4 @@
f[2], f[3] = 0, False
elif word == "endif" and self.frames:
f = self.frames.pop()
if f[1] is not None and f[2] != f[1]:
Member

Compare the implicit empty arm when there is no #else. Guarding the file's final namespace close with _WIN32 currently passes.

Compare the implicit empty arm when there is no `#else`. Guarding the file's final namespace close with `_WIN32` currently passes.
@ -101,0 +122,4 @@
def char(self, number, ch):
if ch not in "{};":
self.code += ch
Member

The ASTC header puts about 359 KB in one initializer. This append repeatedly copies it even where only braces matter. Collect head text only where needed and buffer it in chunks.

The ASTC header puts about 359 KB in one initializer. This append repeatedly copies it even where only braces matter. Collect head text only where needed and buffer it in chunks.
@ -101,0 +126,4 @@
return
step = {"{": 1, "}": -1, ";": 0}[ch]
if step and self.frames:
self.frames[-1][2] += step
Member

An alternate arm can close below file scope and then reopen a brace to get back to zero. Check depth throughout each arm.

An alternate arm can close below file scope and then reopen a brace to get back to zero. Check depth throughout each arm.
@ -101,0 +127,4 @@
step = {"{": 1, "}": -1, ";": 0}[ch]
if step and self.frames:
self.frames[-1][2] += step
if self.following():
Member

Alternate arms skip scope validation but still write self.code. With two platform signatures and one shared body, the Linux signature can hide a misplaced Windows definition.

Alternate arms skip scope validation but still write `self.code`. With two platform signatures and one shared body, the Linux signature can hide a misplaced Windows definition.
@ -101,0 +128,4 @@
if step and self.frames:
self.frames[-1][2] += step
if self.following():
if ch == "{":
Member

destroy_image_later has = {} defaults in vk_internal.h. The first initializer resets the declaration head, so a misplaced definition of this existing renderer function passes.

`destroy_image_later` has `= {}` defaults in `vk_internal.h`. The first initializer resets the declaration head, so a misplaced definition of this existing renderer function passes.
@ -101,0 +154,4 @@
if not m or "=" in head.split("(")[0] or m.group(2) in ("if", "for", "while", "switch", "return", "sizeof"):
return
names = [s[1] for s in self.stack] + [q for q in m.group(1).split("::") if q]
into.append((m.group(2), number, "mkwvk" in names))
Member

A definition in a nested mkwvk::detail namespace can pass. Compare the full scope and distinguish unrelated same-name overloads.

A definition in a nested `mkwvk::detail` namespace can pass. Compare the full scope and distinguish unrelated same-name overloads.
@ -101,0 +160,4 @@
def sources():
"""The repository's renderer sources: tracked files when git can say, else the tree; none outside the checkout"""
try:
listed = subprocess.run(["git", "ls-files", "-z", "--", "gpu/vk"], cwd=ROOT, capture_output=True, check=True).stdout
Member

An inherited Git index override or an enclosing repository can supply the wrong file list. Clear repository overrides and verify the Git root.

An inherited Git index override or an enclosing repository can supply the wrong file list. Clear repository overrides and verify the Git root.
@ -101,0 +167,4 @@
root = ROOT.resolve()
keep = []
for p in paths:
if p.suffix not in SUFFIXES or p.is_symlink() or not p.is_file():
Member

An in-tree symlink in a parent directory passes both filters. Reject linked path components and prune links before traversing the fallback tree.

An in-tree symlink in a parent directory passes both filters. Reject linked path components and prune links before traversing the fallback tree.
d4nkn3ss changed title from test(vk): the brace check holds vk_internal.h's mkwvk functions inside mkwvk, compares each #if's branches and reads only tracked files to WIP: test(vk): the brace check holds vk_internal.h's mkwvk functions inside mkwvk, compares each #if's branches and reads only tracked files 2026-11-21 02:05:47 +00:00
Author
Contributor

Back to work in progress. The review is right on its points. Most of them (default arguments with braces, nested namespaces, an arm that dips below and comes back, an #if with no #else, splices before lexing, Git's environment) need a hand-written C++ parser to get right, and every pass finds the next gap.

The complete guard already exists: CI builds the renderer on Linux (build-linux.yml, longshot_vk.so (build check)) and Windows. #1105's brace and the Linux link break #1961 just fixed both merged before those builds ran on their heads.

So rather than grow this scanner, I'd keep tests/test_vk_braces.py as #1949 left it, a cheap tripwire for the one regression, and close this PR. Or, if maintainers want it, I'll replace both with a -fsyntax-only compile of the renderer sources, run where the Vulkan headers are found and skipped where they aren't. I'm waiting on that choice before doing more.

Posted by an AI agent (Claude Code) for d4nkn3ss.

Back to work in progress. The review is right on its points. Most of them (default arguments with braces, nested namespaces, an arm that dips below and comes back, an `#if` with no `#else`, splices before lexing, Git's environment) need a hand-written C++ parser to get right, and every pass finds the next gap. The complete guard already exists: CI builds the renderer on Linux (`build-linux.yml`, `longshot_vk.so (build check)`) and Windows. #1105's brace and the Linux link break #1961 just fixed both merged before those builds ran on their heads. So rather than grow this scanner, I'd keep `tests/test_vk_braces.py` as #1949 left it, a cheap tripwire for the one regression, and close this PR. Or, if maintainers want it, I'll replace both with a `-fsyntax-only` compile of the renderer sources, run where the Vulkan headers are found and skipped where they aren't. I'm waiting on that choice before doing more. *Posted by an AI agent (Claude Code) for d4nkn3ss.*
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 6s
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/vk-braces-scope:d4nkn3ss-fix/vk-braces-scope'
git switch 'd4nkn3ss-fix/vk-braces-scope'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1960
No description provided.