Skip to content

address copilot review on #111: robust luacParse + looser local-count check#112

Merged
Unisay merged 2 commits into
mainfrom
issue-108/repro-test-review-fixes
Jun 23, 2026
Merged

address copilot review on #111: robust luacParse + looser local-count check#112
Unisay merged 2 commits into
mainfrom
issue-108/repro-test-review-fixes

Conversation

@Unisay

@Unisay Unisay commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #111, applying both Copilot review comments on the parser-nesting reproduction test.

  • Spec.hs:207 — the unflattened local-count assertion was == 1, which is brittle to unrelated codegen changes (e.g. if the emitter later adds a module/runtime-setup local). Relaxed to < 50: still far below Lua's 200-locals cap (so it corroborates "the crash isn't the locals cap"), but robust. The real cause-discriminator is unchanged — luac reports too many syntax levels, a distinct message from its locals error.
  • Spec.hs:250luacParse wrote to a hard-coded /tmp/... path and ran luac via shell string concatenation. Switched to withSystemTempFile (unique, auto-cleaned) + proc "luac" ["-p", file] (argv list, no shell), so it is portable and safe against paths with spaces and concurrent test runs.

Test-only; the assertion still passes and still pins the failure to parser nesting.

- test/.../Lua/Golden/Spec.hs:207 — relax the unflattened local-count check from
  `== 1` to `< 50`, robust to unrelated module/runtime-setup locals; the
  "too many syntax levels" error message is the real cause-discriminator
  (#111 (comment))
- test/.../Lua/Golden/Spec.hs:250 — luacParse now uses withSystemTempFile + a
  `proc "luac" ["-p", file]` argv (no hard-coded /tmp, no shell concat), so it is
  portable and safe against spaces / concurrent runs
  (#111 (comment))

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Lua golden spec regression test added in #111 to be more robust and to invoke luac more safely/portably, while keeping the test’s intent (pinning the failure to Lua parser nesting) intact.

Changes:

  • Relaxes the “unflattened local-count” assertion to be less brittle against unrelated codegen changes.
  • Reworks luacParse to use a unique system temp file and typed-process’s proc (argv-based) invocation rather than a hard-coded /tmp path + shell string.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/Language/PureScript/Backend/Lua/Golden/Spec.hs
Comment thread test/Language/PureScript/Backend/Lua/Golden/Spec.hs
- test/.../Lua/Golden/Spec.hs — luacParse writes through the handle that
  withSystemTempFile provides and hFlushes it, instead of hClose-ing early and
  re-opening the file by path. Avoids the manual-close-of-a-bracket-managed-
  handle smell (and the redundant re-open, which is unportable on Windows).
  (#112 (comment) comments)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@Unisay Unisay merged commit 3b15491 into main Jun 23, 2026
3 checks passed
@Unisay Unisay deleted the issue-108/repro-test-review-fixes branch June 23, 2026 11:47
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.

2 participants