Skip to content

test(vm): pin short-circuit depth-4 semantics; correct constructs skip - #294

Merged
davydog187 merged 4 commits into
mainfrom
fix/short-circuit-level4
May 31, 2026
Merged

davydog187 merged 4 commits into
mainfrom
fix/short-circuit-level4

Conversation

@davydog187

Copy link
Copy Markdown
Contributor

Summary

Bisected the constructs.lua short-circuit harness (lines 287-298) at
level=4, as flagged in #281. The suspected executor short-circuit bug
(register aliasing under conditional-jump bytecode, or a not precedence
wrinkle) does not reproduce.

A faithful in-process replica of the harness — createcases up to
level=4, the if %s then IX = true end; return %s program template, run
through load — passes all 204105 cases for both _ENV.GLOB1 = 0 and
_ENV.GLOB1 = 1. The test_and/test_or CPS path in the executor
evaluates deep ((((a op b) op c) op d) op e) compositions and their
not(...) wrappings correctly.

Reduced findings

The real blockers gating constructs.lua lines 225-313 are upstream of the
harness and unrelated to short-circuiting:

  1. Line 226 assert(debug.getinfo(1, "n").name == 'F') — debug.getinfo
    always returns name = nil; call-stack name introspection is
    unimplemented.
  2. Line 237 _ENV.GLOB1 = math.floor(os.time()) % 2 — os.time is nil
    (the os library is essentially unimplemented). GLOB1 then feeds line
    248's concat and the harness leaf (0==_ENV.GLOB1), so line 237 cannot
    simply be blanked.

Both are out of scope for this issue, which targeted the short-circuit
executor path. This is therefore the "otherwise" branch of #281: no
tractable executor fix, so the skip reason is corrected and the harness is
pinned green by a regression test.

Changes

  • test/lua/vm/short_circuit_test.exs — new regression test pinning the
    short-circuit semantics: explicit depth-4 and/or chains, not
    wrapping, the if-condition side-effect shape, and the level-3 generative
    harness (4105 cases). The full level-4 run (204105 cases) passes
    identically but is too slow for the default suite.
  • test/lua53_skips.exs — constructs.lua skip reason rewritten to name
    the two upstream blockers and reference the issue; previously it wrongly
    implicated a "load()-driven short-circuit harness" edge case.

Why draft

Per #281, the directive was to fix the executor bug if tractable, otherwise
narrow the skip with a precise reason and open a draft documenting the
reduced repro. The executor is correct, so there is no fix to land; this PR
documents that and pins it. Opened as draft for review of the
classification before the skip-reason correction merges.

Validation

  • mix format
  • mix compile --warnings-as-errors
  • mix test — 2051 passed, 22 skipped
  • mix test test/lua53_suite_test.exs --only lua53 — 14 passed, 15 skipped (no delta; constructs.lua stays skipped with an accurate reason)

Plan: A45

Closes #281

🤖 Generated with Claude Code

The constructs.lua short-circuit harness (lines 287-298) was suspected of
exercising an executor short-circuit bug at level=4 register aliasing or a
`not` precedence wrinkle. Bisecting a faithful in-process replica up to
level=4 (204105 cases, both _ENV.GLOB1 values) shows the harness passes
completely: the `test_and`/`test_or` CPS path evaluates deep
`((((a op b) op c) op d) op e)` compositions and their `not(...)` wrappings
correctly. There is no executor bug.

The real blockers gating constructs.lua lines 225-313 are upstream of the
harness and unrelated to short-circuiting: `debug.getinfo(1,"n").name`
returns nil (call-stack name introspection unimplemented) at line 226, and
`os.time` is nil at line 237, feeding `_ENV.GLOB1` used by line 248 and the
harness leaf.

Add a regression test pinning the short-circuit semantics (explicit depth-4
chains, `not` wrapping, the if-condition side-effect shape, and the level-3
generative harness) and rewrite the skip reason to name the two upstream
blockers and reference the issue.

Plan: A45
Closes #281
@davydog187

Copy link
Copy Markdown
Contributor Author

Review: sound investigation, ready to land green

I independently reproduced the central claim. Running the full level-4 harness (204105 cases) in-process with a faithful load install passes completely — no executor short-circuit bug. I also confirmed both upstream blockers are real:

  • os global is nil, so os.time at line 237 raises before the harness runs.
  • debug.getinfo(1,"n").name returns nil, and the assert(... == 'F') in F (called at line 230) fires an assertion failure well before the harness at 287.

So the harness genuinely never executes in the suite, and the previous "load()-driven short-circuit harness" skip reason was indeed a misattribution. The classification holds: this is the "otherwise" branch of #281 — no tractable executor fix, corrected skip reason, harness pinned by regression test. Issue #281's described "fails at ~120000 iterations" symptom does not reproduce on current main (likely fixed by intervening closure/upvalue work, or it was always the blockers masking the harness).

Conventions: all clean. test(vm): subsystem scope; chore(A45) only on plan-only commits (the allowed exception); no plan-id in source/tests/skip-reason; no Co-Authored-By trailer; body has Closes #281. Skip reason is precise and references the issue.

Tests: the 14 cases pass; hand-computed expected values spot-checked correct, including the error() short-circuit-order cases and the if-condition side-effect shape. Generative level-3 harness (4105 cases) is self-contained on default load.

Minor notes (non-blocking)

  1. The regression test pins level 3 (4105 cases) for suite speed; level 4 (the level constructs.lua short-circuit harness fails at level=4 deep composition #281 actually flagged) is only verified by the manual run in the PR narrative, not in CI. Consider a @tag :slow level-4 variant excluded by default so the exact regression surface is reproducible on demand rather than living only in prose.
  2. The test module comment mentions guarding against "register aliasing" and a "not precedence wrinkle" — but the PR's own conclusion is that neither exists. Reads slightly as if pinning a known hazard; a one-line note that these were the suspected (and disproven) mechanisms would keep the comment honest.

Nothing here blocks marking ready once mix test and the --only lua53 suite are green (PR reports both pass with no suite delta).

Pin the exact depth-4 surface (#281) behind a :slow tag so it can be
re-run on demand without bloating the default suite, and correct the
moduledoc to describe the suspected hazards as confirmed-handled rather
than as live bugs.

Closes #281
@davydog187
davydog187 marked this pull request as ready for review May 31, 2026 11:47
@davydog187
davydog187 merged commit d2469cd into main May 31, 2026
5 checks passed
@davydog187
davydog187 deleted the fix/short-circuit-level4 branch May 31, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

constructs.lua short-circuit harness fails at level=4 deep composition

1 participant