Repository navigation
compiler: feed a bare \refstepcounter into the following \label - #486
Merged
Merged
Conversation
Four regression tests in xref_toc.rs: the exact bug-report input, a custom \themyc representation, a section-label precedence check, and two counters proving source-order most-recent-wins. All three value tests fail before the fix (\ref renders empty). Implementation-Agent: muse-spark-1.3-contributor
HOST_PRELUDE wraps \refstepcounter to also emit \flashtexcurrentlabelmarker + \@CurrentLabel's expansion (makeatletter bracketed: @ is Other when the host prelude is tokenized). The converter captures the group into a side-channel map keyed by the pushed flashtexcurrentlabel token's own span (mirroring the arraystretch capture, threaded through the incremental cache's build/update/finish paths), and the parser consumes it in fn command to set current_counter for the next \label. Math paths skip the marker silently so \refstepcounter stays invisible there too. Fixes GH-REFSTEPCOUNTER-LABEL: \newcounter + \refstepcounter + \label + \ref now round-trips instead of rendering an empty \ref. Implementation-Agent: muse-spark-1.3-contributor
Contributor
Author
|
daniel-parent review (subagent) Verdict: READY
|
d-q222
marked this pull request as ready for review
September 15, 2026 06:20
d-q222
added a commit
that referenced
this pull request
Sep 16, 2026
What changed: Resolves the merge of main (122 commits, incl. #486 \refstepcounter) into GH-LIST-LABELS. Both sides add a parallel expansion-pass side channel keyed by a span, so nothing contradicts: `labelitem_overrides` (this branch) and `current_label_by_marker` (#486) now sit alongside `arraystretch` in `Expansion`, `Converter`, `ExpansionCache` and `P`, each with its own capture block, production log, cache splice and incremental shift. Both host prelude wrappers (`\itemize`, `\refstepcounter`) are kept. In parser.rs main had refactored the running-text dispatch into command families, so the `\labelitemi..iv` arm is re-placed next to `\TeX`/`\LaTeX` in the new match, the four names are added to main's rewritten `BUILT_INS`/`TEXT_SYMBOLS` block, and `itemize_default_label` survives alongside main's new `enumerate_reference_value`/`next_list_depths`. Because main now holds the innermost list frame as `list_stack.last_mut()` across the item-label match, that frame is addressed by index so `itemize_default_label` can take `&mut self`. supported.rs keeps main's rewritten penalty/break descriptions plus the four new labelitem entries; the generated artefacts are main's, then regenerated (+4 kernel commands, 199 -> 203). What was run: cargo test (crates/compiler, CARGO_TARGET_DIR=target-merge-422): 77 test binaries, all `test result: ok`, 0 failures test result: ok. 23 passed; 0 failed; 0 ignored (--test list_structure) test result: ok. 11 passed; 0 failed; 0 ignored (--test xref_toc) test result: ok. 10 passed; 0 failed; 0 ignored (--test expansion_incremental) test result: ok. 8 passed; 0 failed; 0 ignored (--test supported_latex) test renewcommand_of_a_labelitem_changes_the_itemize_default_too ... ok test labelitem_commands_typeset_the_kernel_markers ... ok test refstepcounter_on_a_newcounter_feeds_the_following_label ... ok test each_label_reads_the_most_recent_refstepcounter_in_source_order ... ok Next step: Await review/merge by the integration lane. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
This was referenced Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope
GH-REFSTEPCOUNTER-LABEL, fixing issue #447.crates/compiler/src/expansion.rs,parser.rs,math.rs,tests/xref_toc.rs.Overlap check
No other open PR touches
\refstepcounter/\label/current_label_by_marker. Claimed viacoord.pybefore starting.Root cause
\labelis deliberately neutered inHOST_PRELUDE(\let\label\flashtexundefined) so the parser's own"label"handler sees the literal, unexpanded command.\refstepcounter/\stepcounterare NOT neutered — they run as real engine primitives that correctly update the engine's internal\@currentlabel, but produce zero output tokens, so the parser'sself.current_counter(which\labelreads) never learns about a bare, user-issued\refstepcounter{name}for a\newcounter-defined counter — only the parser's own section/equation/theorem counter-stepping ever sets it.Fix
Extended the existing
\arraystretch/\tabularHOST_PRELUDEcapture pattern:\refstepcounteris wrapped (\makeatletter-bracketed, since\@currentlabelneeds catcode 11 for@) to run for real, then emit a marker plus\@currentlabel's current expansion via\expandafter. TheConvertercaptures this intoExpansion::current_label_by_marker, keyed by the pushedflashtexcurrentlabeltoken's own span (there's no enclosing environment to key by here, unlike\tabular). The parser consumes this marker as a pre-matchguard at the top offn command(not a match arm, sincesupported_latex.rs's inventory test scrapes match arms as the user-facing command list, and this is an internal side channel) and setsself.current_counterfrom it. Full incremental-cache threading (build_cache/update_cache/finish) mirrorsstretch_logexactly.math.rssilently skips the marker in three spots so\refstepcounterinside math stays invisible instead of newly diagnosing.Test results (head
52f6dfef, re-run independently by me)Mutation check (re-run by me independently): disabling the
current_label_by_markerlookup's effect (dropping theself.current_counter = Some(text)assignment) makes 3 of the 4 new tests fail with the exact reported symptom (left: ""instead of the real counter value); the 4th (proving section labels still win, unaffected by this code path) correctly still passes. Restoring makes all 4 pass.Not done
A marker inside a raw-text argument group (
\labelkeys, lengths — contexts never dispatched throughfn command) would leak marker text into the reconstruction. No test in this suite exercises that shape; noted as a known limitation, not fixed here.Posted at a time when daniel-parent (the usual reviewer) is at temporarily reduced capacity — this is ready for review whenever they have bandwidth; no urgency implied by opening it as draft now.
🤖 Generated with Claude Code