Option-D w10 follow-ups: scope ANIMAL, ratified terms, protect \ifswedish clamps - #956
Merged
bjornregnell merged 7 commits intoJul 23, 2026
Merged
Conversation
…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).
…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.
Author
|
@bjornregnell ready for review. Seven commits, all verified in a rebuilt
Clean gate run: example gate 10 ok / 0 regressions; leak-check 293 Two review notes: (1) the only invented identifiers are |
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.
Post-merge follow-ups to #948/#949 from BR's review, all verified in a rebuilt
compendium-en.pdf.Changes
Drop the
inmixning supertypoverride — 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 wronginmixning supterpcache row purged, not restored — it's dead now; say if you'd rather have a literal revert.)Scope the ANIMAL cluster to
perFileId["w10-inheritance-exercise"](was global).Djuralso occurs inlect-w11-context's generics demo (class Katt/Hund extends Djur), where a globalDjur→Animalproduced mixedclass Katt extends Animal. Scoping keeps w11 fully Swedish (deferred) while Task 3 still translates. The rest of the cluster occurs only in this file.Mirror leaves code inside
\ifswedishclamps untranslated —translateCodeEnvBodieswas runningrenderCodeIdson code inside hand-written\ifswedish…\else…\ficlamps, mutating the Swedish branch into a mixed listing (the hand-clamped Fyle example rendereddef makeNoise … print(läte*2)). NewLatex.ifswedishRanges(nesting-aware) gives the clamp ranges; both the env pass and inline pass skip matches inside them.Ratified terms (BR):
IckeAkademiker→NonAcademic;Doktorand→"PhD student"(title string →codeStr); lowercaseakademiker→academic,forskare→researcher(Task 5 REPL val names).Clamp the Fyle
räknaLätesolution — the one Fyle block that wasn't\ifswedish-clamped, soväsnascollided (must bemakeNoisein Task 3 buthollerin Fyle — same file, unresolvable by glossary). Hand-clamped using the Fyle example's established terms (väsnas→holler,läte→call,Fyle→Fowlk) plus newräknaLäte→callCount,antalLäten→numberOfCalls. Re-termed BR's existing Pjodd\elseclamp (wascallTally/callCount) to the same scheme so both solutions read consistently. Swedish branches kept byte-identical.Verification
compendium-en.pdfrebuilt: 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/supertypeseparate). NomakeNoise+lätemixing anywhere; nocallTallyleft..tex, 0 code-string leaks.Notes for BR
räknaLäte→callCount,antalLäten→numberOfCallsare the two identifiers I coined (BR-ratified) — the rest reuse your Fyle\elseterms.Phase-1 inline compile gate (#951)
Adds the inline-
.texcompile gate BR scoped in #951, as a second check inscratch/verify-mirror-examples.scala:Code/CodeSmall/lstlisting) thatrenderCodeIdsactually changes and that aren't inside an\ifswedishclamp (reuses the newLatex.ifswedishRanges, so it gates exactly the set the mirror translates)..scalagate: 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 leadinglstlisting[...]option line first. Uses the mirror's per-file overrides so per-file clusters (ANIMAL) are gated too.scala>prompts); Trace/Output aren't compilable Scala. Both counts arelog()-ed so nothing silently reads as "covered".Tested (not just run clean): 23 self-contained inline bodies compile (non-vacuous); an injected
Tomat→Tomatoduplicate-class rename is caught (exit 1) while a\ifswedish-clamped copy of the same break is correctly skipped; robust to a missingexamples/dir.