Skip to content

#5732: preserve compact | pipe when target formation floats away#5736

Draft
yegor256 wants to merge 1 commit into
masterfrom
claude/github-issue-5732-teanvx
Draft

#5732: preserve compact | pipe when target formation floats away#5736
yegor256 wants to merge 1 commit into
masterfrom
claude/github-issue-5732-teanvx

Conversation

@yegor256

Copy link
Copy Markdown
Member

Closes #5732.

Problem

After #5684 the printer emits the | pipe-application form, but the adjacency guard at to-eo-tree.xsl:223 only fires when the pipe target is the immediately-preceding sibling. When a pipe target formation floats up to become a formation attribute (#5526) while its pipe application stays nested inside another expression (the "floated away" case), the guard fails and the line prints as an ordinary application — destroying the compact | args author spelling on the first eo:format. This is exactly the recursive-helper case in eo-runtime/src/main/eo/tuple/front.eo.

merge-monikers.xsl already un-hoists ordinary > name bindings back onto their use-site, but it deliberately skips pipe-floated bindings (not(exists($attr/@pipe))) and references carrying arguments (not($ref/o)) — which is precisely what a | args use is.

Fix

Add renest-pipe-monikers.xsl, a small targeted pass mirroring merge-monikers.xsl, registered right after it in the Xmir train (before to-eo-tree.xsl). For a formation attribute whose only reference is a single @pipe application that no longer sits directly after it, the pass copies the formation back in front of that pipe use-site and drops the floated original. The pipe then reads its predecessor from the immediately preceding sibling, so the existing adjacency guard fires and the | head is emitted. Both spellings parse to identical XMIR, so re-nesting is safe.

It is gated on the formation having exactly one reference which must be the pipe use — the same single-host condition merge-monikers uses (#5706) to keep the round trip converging. A second reference would fall out of scope once the formation moved into the pipe's argument block. A formation already adjacent to its pipe use is left untouched.

Changes

  • renest-pipe-monikers.xsl — the new pass.
  • Xmir.java — register the pass in the transformation train after merge-monikers.
  • to-eo-tree.xsl — update the pipe-application comment to note the floated case is now re-nested upstream.
  • pipe-floated-recursive-helper.yaml — new print-pack modeling the tuple/front.eo recursive helper; the | now survives the round trip.
  • pipe-in-argument-block.yaml — updated expected output: the pipe is now preserved instead of degrading to a bare application.

Testing

XmirTest (all 139 parameterized print-pack / eo-pack cases) passes, including the round-trip check that printed EO reprints to the very same EO.


Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Benchmark Comparison Unavailable

Unfortunately, one of the benchmarks is missing, and we couldn't generate a performance comparison report.

Please ensure that both the base and PR benchmark results are available for analysis.

The printer emitted the `|` pipe-application form (#5684) only when the
pipe target was the immediately-preceding sibling. When a pipe target
formation floats up to become a formation attribute (#5526) while its
pipe application stays nested inside another expression, the adjacency
guard in `to-eo-tree.xsl` failed and the line printed as an ordinary
application, destroying the compact author spelling on the first format.

Add `renest-pipe-monikers.xsl`, a targeted pass mirroring
`merge-monikers.xsl`, that relocates a floated pipe target formation back
down to nest directly above its single pipe use-site, so the adjacency
guard fires and the `|` is emitted. Gated on the formation having exactly
one reference which must be the pipe use, matching the single-host
convergence condition (#5706).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TipwHhMMamjeKKum4ggWLw
@yegor256
yegor256 force-pushed the claude/github-issue-5732-teanvx branch from 3c57765 to 62e1020 Compare July 24, 2026 05:42
@sonarqubecloud

Copy link
Copy Markdown

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.

Loss of compact | pipe during eo-printer formatting when target formation becomes a formation attribute

2 participants