Skip to content

Commit aef4869

Browse files
respencer-nclclaude
andcommitted
Update CLAUDE.md and NOTEBOOK.md for 1.2.3 release
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 5bcfbc6 commit aef4869

2 files changed

Lines changed: 106 additions & 3 deletions

File tree

CLAUDE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,32 @@ When implementing new code:
301301
**Cause**: sbt-ossuminc 1.0.0 API change
302302
**Fix**: Use `With.ScalaJS` instead
303303

304+
### Error: "No given instance of PlatformContext for default parameter"
305+
**Cause**: Scala 3.7.4 limitation — default parameter values in a case
306+
class's first parameter list cannot resolve `given` instances from a
307+
subsequent `using` clause in the generated companion `apply` method.
308+
**Fix**: Remove the default value. May be fixed in 3.9.x LTS.
309+
**Example**:
310+
```scala
311+
// This fails in 3.7.4:
312+
case class Foo(x: Bar = Bar())(using PlatformContext)
313+
// Fix: remove default (or provide explicit given)
314+
case class Foo(x: Bar)(using PlatformContext)
315+
```
316+
317+
### Error: "parameters with defaults must be at the end" (Scala.js)
318+
**Cause**: `@JSExportTopLevel` on a case class with `(using
319+
PlatformContext)` in a second parameter list. The JS export sees the
320+
context parameter as a non-default parameter after defaulted params.
321+
**Fix**: Remove `@JSExportTopLevel` from internal data structures that
322+
don't need to be constructed from JS code.
323+
324+
### System.lineSeparator() returns null in Scala.js
325+
**Cause**: `System.lineSeparator()` returns `\0` in Scala.js
326+
**Fix**: Use `PlatformContext.newline` instead. Never use
327+
`System.lineSeparator()` in shared code. The `FileBuilder` trait
328+
and its entire hierarchy use `(using PlatformContext)` for this.
329+
304330
## File Organization
305331

306332
### Creating New Modules
@@ -622,3 +648,7 @@ Then add to root aggregation: `.aggregate(..., mymodule, mymoduleJS, mymoduleNat
622648
14. **BAST location comparisons use offsets** - Compare offset/endOffset, not line/col
623649
15. **Scala version changes require workflow updates** - Update `scala-X.Y.Z` paths in workflows
624650
16. **All RIDDL documentation goes to ossum.tech** - Don't add docs to this repo's `doc/` directory
651+
17. **Never use System.lineSeparator() in shared code** - Use `PlatformContext.newline` instead; returns `\0` in Scala.js
652+
18. **FileBuilder requires PlatformContext** - `trait FileBuilder(using PlatformContext)` — all subclasses must propagate the using clause
653+
19. **Scala 3.7.4 default param limitation** - Case class defaults can't resolve givens from a subsequent using clause in generated apply; remove defaults or provide explicit givens
654+
20. **@JSExportTopLevel incompatible with using clauses** - Don't use on case classes that have `(using PlatformContext)` in a second parameter list

NOTEBOOK.md

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ This is the central engineering notebook for the RIDDL project. It tracks curren
1212
compiler infinite loop bug with opaque types/intersection types in 3.3.x).
1313
All workflow paths updated to `scala-3.7.4`.
1414

15-
**Release 1.2.2 Published**: Fixed Scala.js null newline bug that was causing error
16-
message truncation in synapify. All 715 tests pass. Published to GitHub Packages.
15+
**Release 1.2.3 Published**: Comprehensive fix for all
16+
`System.lineSeparator()` calls in shared code that returned `\0` in
17+
Scala.js. Added `(using PlatformContext)` to `FileBuilder` trait and
18+
propagated through entire hierarchy. All tests pass. Published to
19+
GitHub Packages. Merged to main.
1720

1821
**Packaging Infrastructure**: Docker, npm, and TypeScript support added:
1922
- `Dockerfile` — Multi-stage build with custom JRE via jlink (~80-100MB image)
@@ -153,6 +156,76 @@ The `pseudoCodeBlock` parser now allows comments before and/or after `???`:
153156

154157
## Session Log
155158

159+
### February 3, 2026 (Release 1.2.3 - System.lineSeparator Fix)
160+
161+
**Focus**: Comprehensive fix for `System.lineSeparator()` returning
162+
`\0` null bytes in Scala.js shared code
163+
164+
**Root Cause**: `System.lineSeparator()` returns `\0` in Scala.js,
165+
not just in `Messages.scala` (fixed in 1.2.2) but throughout all
166+
shared code including `FileBuilder`, `StringHelpers`, and command
167+
files.
168+
169+
**Approach**: The architecturally correct fix — added
170+
`(using PlatformContext)` trait parameter to `FileBuilder` and
171+
propagated through the entire class hierarchy. This ensures all
172+
code uses `pc.newline` which returns the correct value per platform.
173+
174+
**Work Completed**:
175+
1.**Fixed JVM/Native PlatformContext** — Changed hardcoded
176+
`"\n"` to `System.lineSeparator()` (correct on these platforms)
177+
2.**Fixed Messages.scala** — Changed `System.lineSeparator()`
178+
to existing `nl` constant
179+
3.**Fixed StringHelpers.toPrettyString** — Added
180+
`(using PlatformContext)`, uses `pc.newline`
181+
4.**Fixed FileBuilder hierarchy** — Added
182+
`(using PlatformContext)` trait parameter, propagated through:
183+
`OutputFile`, `TextFileWriter`, `RiddlFileEmitter`,
184+
`PrettifyState`, `PrettifyVisitor`, `PrettifyOutput`
185+
5.**Fixed Command files** — Replaced `System.lineSeparator()`
186+
with `io.newline`/`pc.newline` in `Command.scala`,
187+
`HelpCommand.scala`, `AboutCommand.scala`
188+
6.**Fixed JS export issues** — Removed `@JSExportTopLevel`
189+
from `PrettifyState` and `PrettifyOutput` (incompatible with
190+
`using` parameter lists in Scala.js exports)
191+
7.**All tests pass** — 715+ JVM tests, JS and Native compile
192+
8.**Released 1.2.3** — Tagged, published to GitHub Packages,
193+
merged to main, GitHub release created
194+
195+
**Scala 3.7.4 Compiler Limitation Discovered**:
196+
Default parameter values in a case class's first parameter list
197+
cannot resolve `given` instances from a subsequent `using` clause
198+
in the generated companion `apply` method. Worked around by
199+
removing the default value for `PrettifyOutput.state` (only call
200+
site provides it explicitly anyway). Documented with comment noting
201+
potential fix in 3.9.x LTS.
202+
203+
**Commits** (on development, merged to main):
204+
- `5bcfbc68` - Fix System.lineSeparator() returning null bytes in
205+
Scala.js
206+
207+
**Files Modified** (18 files):
208+
- `utils/shared/.../FileBuilder.scala` — trait parameter
209+
- `utils/shared/.../StringHelpers.scala` — using clause
210+
- `utils/shared/test/.../StringHelpersTest.scala`
211+
- `utils/jvm/.../JVMPlatformContext.scala`
212+
- `utils/native/.../NativePlatformContext.scala`
213+
- `utils/jvm-native/.../OutputFile.scala`
214+
- `utils/jvm-native/.../TextFileWriter.scala`
215+
- `utils/jvm/test/.../FileBuilderTest.scala`
216+
- `utils/jvm/test/.../TextFileWriterTest.scala`
217+
- `language/shared/.../Messages.scala`
218+
- `passes/shared/.../PrettifyPass.scala`
219+
- `passes/shared/.../PrettifyState.scala`
220+
- `passes/shared/.../PrettifyVisitor.scala`
221+
- `passes/shared/.../RiddlFileEmitter.scala`
222+
- `passes/jvm-native/test/.../RiddlFileEmitterTest.scala`
223+
- `commands/shared/.../Command.scala`
224+
- `commands/shared/.../AboutCommand.scala`
225+
- `commands/shared/.../HelpCommand.scala`
226+
227+
---
228+
156229
### February 3, 2026 (Packaging Infrastructure)
157230

158231
**Focus**: Packaging infrastructure for Docker, npm, TypeScript, and
@@ -995,4 +1068,4 @@ Tool(
9951068
## Git Information
9961069

9971070
**Branch**: `main`
998-
**Latest release**: 1.2.2 (February 3, 2026)
1071+
**Latest release**: 1.2.3 (February 3, 2026)

0 commit comments

Comments
 (0)