From bfd9af8f9518a6fe87cbb706813cd87c8dc5ea90 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sun, 1 Nov 2026 12:32:14 -0800 Subject: First cut parser split --- chapter29/README.md | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'chapter29/README.md') diff --git a/chapter29/README.md b/chapter29/README.md index 9ddf69ce..15ddc1a9 100644 --- a/chapter29/README.md +++ b/chapter29/README.md @@ -33,14 +33,25 @@ are parsed after their bodies, and declared constructors after field discovery. The [source layout](src/main/java/com/seaofnodes/simple/README.md) describes the other packages. `IterPeeps` now lives in `codegen/` beside the compilation passes. -## Cleanup still to do - -Constructor completion is a useful next target. `addReturn` already merges field -values across exit paths, but `_ctorExits` saves those types until all fields -are known. Checking the final `Return` alone is insufficient today: field -conversions can erase uninitialized state, and the declaration initializer is -separate from the user constructor. Simplify that bookkeeping without weakening -the initialization checks. +## Checking constructor completion + +`addReturn` merges field values across exit paths. After `parseBody` finishes, +`Structs.parseInitializer` checks the completed helper Returns; no separate exit +maps survive scope teardown. Required fields without an assignment on every +returning path retain `TOP` in private memory. They emit no Store, so numeric +conversions cannot hide the missing assignment. + +The declaration initializer and user constructor have separate Returns. Check +the user constructor when present, or the declaration initializer for the default +constructor. The older same-named constructor binding can precede field +declarations; fields absent from its Return use the declaration initializer's +result. Nonreturning helpers require no completed object. Completion errors +point to the relevant helper's source location. + +`ConstructorCompletionTest` covers partial numeric assignments, early returns, +nonreturning paths, declaration defaults, and fields declared after constructors. + +## Further cleanup Source privacy is deferred. Leading underscores retain the existing export filtering behavior; this chapter does not yet enforce access restrictions on -- cgit v1.2.3