Skip to content

compiler: general factor-by-length dimensions and register readback (#835) - #863

Merged
jay3332 merged 4 commits into
mainfrom
muse/llap-dimensions
Sep 19, 2026
Merged

jay3332 merged 4 commits into
mainfrom
muse/llap-dimensions

Conversation

@d-q222

@d-q222 d-q222 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Fixes the reusable parts of #835, found in a real user's custom question environment.

Three defects

1. A coefficient times a length register was rejected. \setlength{\topsep}{0.6\baselineskip} errored. TeX allows <factor><length> anywhere a dimension is expected. parse_dimen_pt_with_units now accepts it for every real TeX/LaTeX length name — a new FACTOR_LENGTHS covering TeX dimen/skip params, list lengths and \z@/\z@skip — not just the preamble lengths an earlier PR special-cased.

2. \newlength registers did not read back as dimensions. \newlength{\qnumsep}\setlength{\qnumsep}{1em}\hspace{\qnumsep} gave got ''. New FlashtexHspace/FlashtexVspace primitives absorb the star and {<dimen>} in one expansion pass and splice exactly-[<factor>]<register> to fixed-point text. A bare skip splices full \the-style glue so \vspace keeps its stretch; anything else passes through unchanged.

3. \llap's diagnostic suggested "did you mean \flat?" — actively misleading. llap/rlap now join KNOWN_UNIMPLEMENTED_COMMANDS, giving an honest "not supported" with no bogus suggestion. \llap itself is still not implemented; this fixes the advice, not the feature. \clap (mathtools-only) untouched.

Oracle-verified values

Live pdflatex (pdfTeX 1.40.29, TeX Live 2026), 11pt article, 1 page each, pages via pdfinfo:

expression value
0.6\baselineskip 8.16008pt
\parindent 17.0pt (2\parindent = 34.0pt; at 10pt: 15.0/12.0 leading)
\qnumsep (0.6em) 6.57007pt
2\zerolen 0.0pt
-.5\textwidth −180pt

Negative factors, bare factors, zero-valued registers and undeclared registers (which must still error, naming the register) are all covered.

Tests

cargo test -p flashtex-compiler: exit 0, 87 binaries ok, 1,064 passed, 0 failed. New register_space_lengths (7 tests) and llap_and_rlap_are_known_unimplemented_not_flat_typos.

Housekeeping

Merged origin/main (f189d339); the publish gate had refused the raw branch because it would have deleted the KOMA class-geometry work. Re-ran apps/mac/scripts/sync-supported-latex.sh, since the lane changed the vocabulary but cannot touch apps/**.

⚠️ Lands in crates/compiler and crates/tex-expansion, so the compiler half does not reach users until vendor/compiler is re-pinned.

Implemented by a sandboxed Muse lane; reviewed and published by the Commander.

🤖 Generated with Claude Code

… args (#835)

Route \hspace/\hspace*/\vspace through flashtexhspace/flashtexvspace
shims that absorb the star and {<dimen>} with one expansion pass and
splice [<factor>]<register> to its fixed-point value text, so a
\newlength register never reaches the stomach as an assignment
("Missing number" + "Illegal unit" + parser "got ''"). Anything
else passes through verbatim; the shim never reports.

Implementation-Agent: muse-spark-1.3-contributor
Commit-Executor: muse-spark-1.3-contributor
… llap vocab (#835)

Bug 1: parse_dimen_pt_with_units accepts <factor><length> for every
real TeX/LaTeX length name (FACTOR_LENGTHS), not just preamble
lengths; hspace/vspace read dimen_source so the backslash survives;
enlargethispage tries baselineskip_multiple first so its real leading
is not shadowed by the new zero-acceptance. Unowned values stay 0.0
(the preamble-length convention); bare factors and undeclared
registers still error.
Bug 2 (compiler side): prelude routes hspace/vspace through the new
engine shims; done-markers map back in the converter.
Bug 3: llap/rlap join KNOWN_UNIMPLEMENTED_COMMANDS, killing the
misleading 'did you mean \\flat?' (no implementation yet).

Implementation-Agent: muse-spark-1.3-contributor
Commit-Executor: muse-spark-1.3-contributor
#845's `fn is_list_length` landed adjacent to this branch's `FACTOR_LENGTHS`
plus `fn is_length_name`. Same shape as the conflict in #860: this branch's
side ends mid-function body and is closed by the `}` that follows the conflict
block, so concatenating both sides yields an unclosed delimiter. Closed
is_length_name explicitly and let is_list_length take the trailing brace.

Verified: cargo check 0 errors; is_length_name, is_list_length and
is_length_reference each present exactly once; no conflict markers.

Commit-Executor: daniel-parent
Co-authored-by: Claude Opus 5 <[email protected]>
@d-q222

d-q222 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

CI failure diagnosed and reproduced locally: a debug/release divergence. cargo test --release fails on both macOS and Ubuntu; cargo test (debug) passes. I had only run debug, which is why I published this as green — my mistake, and exactly the trap crates/perf-bench/README.md warns about for #667.

The failure

parser::tests::list_topsep_accepts_a_baselineskip_factor --- FAILED
test result: FAILED. 468 passed; 1 failed
panicked at src/parser.rs:17209:
[Diagnostic { severity: Warning,
  message: "unsupported length expression",
  span: Some(Span { start: 55, end: 65 }),
  recovery: Some("ignored the l…

Deterministic — 3 for 3 in release, 0 for 3 in debug.

What the span points at

source[55..65] = "\setlength"
source[65..92] = "{\topsep}{0.6\baselineskip}"

So in release the {decl} group's \setlength{\topsep}{0.6\baselineskip} falls through to "unsupported length expression", while in debug the new <factor><length> path accepts it. The test asserts parsed.diagnostics.is_empty() and then checks extra_gap_before_pt == 7.2 (0.6 × the 10pt class's 12pt leading).

This is the core feature of this PR — a coefficient times a length register — failing in the build configuration users actually ship. It is not a flaky test or an environment artifact.

Likely direction, not yet confirmed

The FACTOR_LENGTHS lookup and the dimen_source raw-text capture are the two new moving parts. A debug-only pass suggests something whose behaviour differs under optimisation — a float comparison, a slice/borrow that debug happens to keep alive, or a lookup whose result debug and release disagree on. Worth checking whether the factor parse depends on a value that is only populated in one configuration.

Required before this can merge

  1. Root-cause the divergence — do not "fix" it by loosening the assertion. extra_gap_before_pt == 7.2 is the measured oracle value (0.6\baselineskip = 8.16008pt at 11pt, 7.2pt at 10pt class leading) and is the point of the feature.
  2. Acceptance now requires BOTH cargo test -p flashtex-compiler and cargo test --release -p flashtex-compiler green. I'm adding that to every lane brief — debug-only verification is insufficient in this repo.

Laning the fix.

@jay3332
jay3332 merged commit 6ebfbeb into main Sep 19, 2026
20 of 22 checks passed
jay3332 added a commit that referenced this pull request Sep 19, 2026
… heads

Two integration fixes for the merges just above, each pinned by a test.

#863 (factor-by-length dimensions) made `parse_dimen_pt_current` accept
`<factor>\baselineskip` as an unvalued `FACTOR_LENGTHS` reference, which
shadowed main's own `baselineskip_multiple` fallback for list lengths
(8a24707): `\setlength{\topsep}{0.6\baselineskip}` inside a list warned
"unsupported length expression" instead of resolving 7.2pt
(`list_topsep_accepts_a_baselineskip_factor`). The leading multiple is now
tried first, in `apply_length_value` and in `calc_chain_term_pt_current` —
the same reorder #863 itself applied to `\enlargethispage`.

#950 (environment bodies as real groups) emits the environment's
`\begingroup` brace directly ahead of every reconstituted `\begin{name}`,
so beamer's optional `{title}{subtitle}` scan after `\begin{frame}` read a
nested `\begin{itemize}`/`\begin{columns}` as a title group and reported
"argument to \frame is missing its closing brace" (5 failures in
`beamer_blocks`/`beamer_overlays`). `environment_group_open_at` tells that
brace apart (a literal `{` ahead of an environment is followed by the
environment's own brace, never by `\begin` itself), and the four
`\@ifnextchar\bgroup`-style scans — frame head, `\onslide`, `\note`, the
theme declarations — use `next_opens_literal_group`. Real `\column{...}`
/ `\frame{...}` argument parsing is untouched (their braces are literal).

Implementation-Agent: Claude Code (mac-claude-a / lane-integrate2)
Commit-Executor: git via Claude Code
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
jay3332 added a commit that referenced this pull request Sep 19, 2026
…he integration batch + package definitions

The pin reads main again after the second integration pass (#827 cherry-picks,
#863, #950, #737/#739/#758/#732/#740/#825, visual-oracle tooling) and the
`metadata.packages` work (`crate::package_definitions`, tex-expansion's
`package_defs.rs`). `git archive` of this tree's `crates/compiler` and
`crates/tex-expansion`, PINs at the merge commit, VENDORING.md rows updated,
`scripts/check-vendor-pins.sh` both "up to date". render-pipeline 819/0 in
both profiles against the new pins; compiler 1368/0, tex-expansion 150/0
release; Mac inventory sync current; swift build clean.

Implementation-Agent: Claude Code (mac-claude-a)
Commit-Executor: git via Claude Code
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
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