Skip to content

s2: C emit and the s2c driver; s2c self-hosts with a byte-identical fixpoint (B2, B3) - #24

Merged
vic merged 1 commit into
mainfrom
selfhost-b2b3
Nov 9, 2026
Merged

vic merged 1 commit into
mainfrom
selfhost-b2b3

Conversation

@vic

@vic vic commented Nov 9, 2026

Copy link
Copy Markdown
Owner

s2/emit.srs prints C for the elaborated program at its mono instances (rules from s1/emit.srs). s2c/main.srs is the driver: it reads the files, parses, type-checks and emits. A clash goes to stderr and the exit code is 1.

El.Fn now has a typed body (Def, Extern or Spec), and Ty.Result also holds the elaborated handlers and givens.

Gate (tests/run.sh, 207 ok, 0 FAIL):

  • s1 builds s2c0. s2c0 compiles prelude + s2 + s2c to s2c1.c. s2c1 compiles the same files to identical C (fixpoint).
  • s2c1 compiles each tests/s2 program. Each one runs and its output equals its .out (18 programs).
  • A program with a clash: exit 1, "line 1: type mismatch", no C.
  • coll at -O0: self tail calls are loops (a 1M list in constant stack).

Mutants: a wrong arm tag kills coll (exit 134); no tail jumps kills coll at -O0 (exit 139).

Known gaps: bead vic-m5r.31.1 (generic givens, mono roots for handler and given fns, generic externs, no clash for an unknown type name).

@vic
vic merged commit 499c34b into main Nov 9, 2026
3 checks passed
@vic
vic deleted the selfhost-b2b3 branch November 17, 2026 16:49
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.

1 participant