Skip to content

Option-D w10 follow-ups: scope ANIMAL, ratified terms, protect \ifswedish clamps - #956

Merged
bjornregnell merged 7 commits into
lunduniversity:masterfrom
hmiddelk:option-d-animal-scope
Jul 23, 2026
Merged

Option-D w10 follow-ups: scope ANIMAL, ratified terms, protect \ifswedish clamps#956
bjornregnell merged 7 commits into
lunduniversity:masterfrom
hmiddelk:option-d-animal-scope

Conversation

@hmiddelk

@hmiddelk hmiddelk commented Jul 21, 2026

Copy link
Copy Markdown

Post-merge follow-ups to #948/#949 from BR's review, all verified in a rebuilt compendium-en.pdf.

Changes

  1. Drop the inmixning supertyp override — BR fixed the missing comma at source (plan/Plan.scala, 53730d5, closes Concept list: 'inmixning supertyp' fused into one item (missing comma in plan/Plan.scala W10 contents) #952), so the concept-list item is now two concepts (inmixning→mixin, supertyp→supertype) translating on their own. The autotranslate: fix half-translated concept-list terms (topptyp/bottentyp/inmixning supertyp) #949 workaround is removed. (Left the wrong inmixning supterp cache row purged, not restored — it's dead now; say if you'd rather have a literal revert.)

  2. Scope the ANIMAL cluster to perFileId["w10-inheritance-exercise"] (was global). Djur also occurs in lect-w11-context's generics demo (class Katt/Hund extends Djur), where a global Djur→Animal produced mixed class Katt extends Animal. Scoping keeps w11 fully Swedish (deferred) while Task 3 still translates. The rest of the cluster occurs only in this file.

  3. Mirror leaves code inside \ifswedish clamps untranslatedtranslateCodeEnvBodies was running renderCodeIds on code inside hand-written \ifswedish…\else…\fi clamps, mutating the Swedish branch into a mixed listing (the hand-clamped Fyle example rendered def makeNoise … print(läte*2)). New Latex.ifswedishRanges (nesting-aware) gives the clamp ranges; both the env pass and inline pass skip matches inside them.

  4. Ratified terms (BR): IckeAkademiker→NonAcademic; Doktorand→"PhD student" (title string → codeStr); lowercase akademiker→academic, forskare→researcher (Task 5 REPL val names).

  5. Clamp the Fyle räknaLäte solution — the one Fyle block that wasn't \ifswedish-clamped, so väsnas collided (must be makeNoise in Task 3 but holler in Fyle — same file, unresolvable by glossary). Hand-clamped using the Fyle example's established terms (väsnas→holler, läte→call, Fyle→Fowlk) plus new räknaLäte→callCount, antalLäten→numberOfCalls. Re-termed BR's existing Pjodd \else clamp (was callTally/callCount) to the same scheme so both solutions read consistently. Swedish branches kept byte-identical.

Verification

  • Full compendium-en.pdf rebuilt: Task 3 (Animal/makeNoise/Mooooo), Task 5 (Person/Academic/Researcher/NonAcademic, "PhD student", val academic/researcher), main Fyle example (Fowlk/holler/call), both Fyle solutions (callCount/numberOfCalls, no mixing), w11 block consistently Swedish, concept list (mixin/supertype separate). No makeNoise+läte mixing anywhere; no callTally left.
  • Compile+leak gate: 10 ok, 0 regressions; 293 .tex, 0 code-string leaks.

Notes for BR

  • räknaLäte→callCount, antalLäten→numberOfCalls are the two identifiers I coined (BR-ratified) — the rest reuse your Fyle \else terms.
  • Pre-existing prose mistranslations in the räknaLäte subtask question ("Before a method…", "a certain frog") are model/cache issues, unrelated to this PR — flag if you'd like them addressed separately.

Phase-1 inline compile gate (#951)

Adds the inline-.tex compile gate BR scoped in #951, as a second check in scratch/verify-mirror-examples.scala:

  • Gates the display Scala-code envs the mirror rewrites (Code/CodeSmall/lstlisting) that renderCodeIds actually changes and that aren't inside an \ifswedish clamp (reuses the new Latex.ifswedishRanges, so it gates exactly the set the mirror translates).
  • Same regression rule as the autotranslate: fix s-interpolation example-compile break + CI compile gate #950 .scala gate: compile the Swedish body and the rendered English body; regression = Swedish compiles but English doesn't; skip if both fail (neighbour-context/signature-only/script-style bodies self-skip). Strips a leading lstlisting[...] option line first. Uses the mirror's per-file overrides so per-file clusters (ANIMAL) are gated too.
  • REPL transcripts deferred to phase 2 (need splitting on scala> prompts); Trace/Output aren't compilable Scala. Both counts are log()-ed so nothing silently reads as "covered".

Tested (not just run clean): 23 self-contained inline bodies compile (non-vacuous); an injected Tomat→Tomato duplicate-class rename is caught (exit 1) while a \ifswedish-clamped copy of the same break is correctly skipped; robust to a missing examples/ dir.

hemiddel added 5 commits July 21, 2026 23:07
…ource lunduniversity#952)

BR fixed the missing comma in plan/Plan.scala (53730d5), so the concept-list item
is now two separate concepts — `inmixning`->mixin and `supertyp`->supertype — each
translating via its existing cache row. The lunduniversity#949 workaround override
`inmixning supertyp` -> `mixin supertype` is therefore vestigial; remove it.

(Left the wrong `inmixning supterp` cache row purged rather than restoring it —
it's dead now, and re-adding a typo'd translation to the committed cache seemed
worse than a literal revert. Say the word if you'd rather have the row back.)
…demiker

Two changes from BR's post-lunduniversity#948 review:

1. ANIMAL cluster (Djur/Ko/Gris/Häst/väsnas/skapaDjur/bondgård) moved from the
   GLOBAL id map into perFileId["w10-inheritance-exercise"]. `Djur` also occurs in
   lect-w11-context's generics demo (class Katt/Hund extends Djur), where Katt/Hund
   aren't glossary'd — a global Djur->Animal rendered `class Katt extends Animal`
   (mixed). Scoping keeps w11 fully Swedish until that lecture is translated, while
   Task 3 in w10-inheritance-exercise still translates. (Ko/Gris/Häst/väsnas/
   skapaDjur/bondgård occur ONLY in that file, so nothing else changes.)

2. IckeAkademiker -> NonAcademic added to the global PERSON cluster (BR-ratified).
   Renders the case class + the prose \code{IckeAkademiker} in Task 5.
translateCodeEnvBodies ran renderCodeIds on ALL Scala-code envs + inline \code,
including those inside hand-written \ifswedish...\else...\fi clamps. Both branches
of a clamp are already final, so translating there mutated the Swedish branch into
a mixed listing — e.g. the hand-clamped Fyle-bird example (w10-inheritance-exercise)
rendered `def makeNoise ... print(läte * 2)` (väsnas renamed, läte/Fyle/Kråga not),
diverging from its crafted English \else branch (Fowlk/holler/call).

Fix: new Latex.ifswedishRanges (nesting-aware via matchFi) gives the char ranges of
every \ifswedish...\fi block; the env pass and the inline pass both skip a match
whose start falls in a clamp (inline ranges recomputed on the post-env text since
env substitution shifts offsets). Verified: Task 3's unclamped REPL/Code still
translate; the Fyle clamp is left byte-identical in both branches.
…rskare

BR-ratified 2026-07-21, both from Task 5's REPL example:
- codeStr "Doktorand" -> "PhD student" (the Researcher's title string value; string
  DATA so it needs codeStr, not the id map).
- lowercase val-name forms akademiker->academic, forskare->researcher (same words
  as the Academic/Researcher classes, lowercased per Scala val convention). Removes
  the `val forskare = new Researcher(...)` mixing.
…odd terms

The räknaLäte subtask (question + solution) was the one Fyle block NOT \ifswedish-
clamped, so the mirror translated it and väsnas collided — it must be makeNoise in
Task 3 (farm) but holler in Fyle (birds), same file, which no per-file glossary can
resolve. Hand-clamp its code refs (\ifswedish<sv>\else<en>\fi) using the terms
already established by the Fyle example's \else branch: väsnas->holler, läte->call,
Fyle->Fowlk. Swedish branches kept byte-identical.

New identifiers räknaLäte->callCount (var), antalLäten->numberOfCalls (method),
BR-ratified 2026-07-22. Re-termed BR's existing Pjodd \else clamp (was callTally/
callCount) to the same scheme so both Fyle solutions read consistently.

Verified in compendium-en.pdf: no makeNoise/läte mixing; both solutions render
callCount/numberOfCalls; Swedish build unaffected (clamp \ifswedish branches).
hemiddel added 2 commits July 22, 2026 13:16
…ty#951)

Extends the mirror gate with the inline-code compile check BR scoped in lunduniversity#951.
For each Code/CodeSmall/lstlisting body in the .tex corpus that renderCodeIds
actually rewrites and that is NOT inside an \ifswedish clamp (Latex.ifswedishRanges
— the mirror leaves clamped code alone), compile the Swedish body AND the rendered
English body. REGRESSION = Swedish compiles but English does not; skip if BOTH fail
(many inline bodies aren't standalone-compilable: neighbour context / signature-only
/ script style — self-skipping beats false alarms). Strips a leading lstlisting
optional-arg line before compiling. Uses the mirror's per-file overrides
(renderCodeIds(body, extraId)) so per-file clusters (e.g. ANIMAL) are gated too.

REPL transcripts are DEFERRED to phase 2 (they need splitting on `scala>` prompts);
Trace/Output aren't compilable Scala. Both counts are logged so nothing silently
reads as "covered". Also guards os.walk against a missing examples/ dir.

Tested: 23 self-contained inline bodies compile clean (non-vacuous); an injected
Tomat->Tomato duplicate-class rename is caught (exit 1) while a \ifswedish-clamped
copy of the same break is correctly skipped.
Optional `--list` flag prints the per-body phase-1 classification — each rewritten
inline Scala-code env as `file:line (env) -> ok|skip` — so you can see exactly
which sections compile after rename and which are skipped (compile in neither
language = not standalone: neighbour context / signature-only / script style).
Normal runs stay quiet. @main now takes varargs so `-- . --list` works in any order.
@hmiddelk

Copy link
Copy Markdown
Author

@bjornregnell ready for review.

Seven commits, all verified in a rebuilt compendium-en.pdf (not just the mirrored .tex):

Clean gate run: example gate 10 ok / 0 regressions; leak-check 293 .tex / 0 leaks; phase-1 23 ok / 30 skipped / 97 REPL deferred / 0 regressions.

Two review notes: (1) the only invented identifiers are callCount/numberOfCalls — everything else reuses existing terms; (2) pre-existing prose mistranslations in the räknaLäte question ("Before a method…", "a certain frog") are model/cache issues unrelated to this PR — happy to address separately if you want.

@bjornregnell
bjornregnell merged commit be87302 into lunduniversity:master Jul 23, 2026
2 checks passed
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.

Concept list: 'inmixning supertyp' fused into one item (missing comma in plan/Plan.scala W10 contents)

3 participants