Skip to content

fix native compiler class field initializers, add boolean[] tests#491

Merged
cs01 merged 3 commits intomainfrom
feat/boolean-array
Mar 20, 2026
Merged

fix native compiler class field initializers, add boolean[] tests#491
cs01 merged 3 commits intomainfrom
feat/boolean-array

Conversation

@cs01
Copy link
Owner

@cs01 cs01 commented Mar 20, 2026

Summary

  • Fix class field initializers in native compilerclass Foo { x: number = 42; } now works when compiled by the native compiler. Previously, field initializers were silently ignored, leaving fields at zero/null defaults.
  • Root cause: classFields[fi] from an ObjectArray lost its ClassField type info in the native compiler, so cf.initializer read field index 0 (name) instead of index 3 (initializer). Fixed by adding as ClassField type assertions on ObjectArray element access.
  • Un-skip class-field-init test — instance field initializers now pass with native compiler
  • Un-skip switch-string-toplevel test — top-level string switch works correctly
  • Add 4 boolean array test fixtures — validates boolean[] support (literals, push, index assignment, prime sieve)
  • Normalize ClassField creation sites — all object literals now include all 5 fields upfront, preventing struct layout mismatches in the native compiler

Test plan

  • npm run verify:quick passes (tests + self-hosting Stage 1)
  • class-field-init.ts passes with native compiler (previously skipped)
  • switch-string-toplevel.ts passes with native compiler (previously skipped)
  • All 4 boolean array tests pass with native compiler
  • Boolean array prime sieve produces correct primes up to 50

@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2026

Benchmark Results (Linux x86-64)

Benchmark C ChadScript Go Node Bun Place
Binary Trees 1.356s 1.204s 2.702s 1.175s 1.027s 🥉
Cold Start 0.8ms 0.8ms 1.2ms 23.8ms 8.7ms 🥇
Fibonacci 0.815s 1.472s 1.564s 3.164s 1.942s 🥈
File I/O 0.123s 0.093s 0.087s 0.207s 0.177s 🥈
JSON Parse/Stringify 0.004s 0.005s 0.017s 0.015s 0.007s 🥈
Matrix Multiply 0.488s 0.719s 0.573s 0.377s 0.340s #5
Monte Carlo Pi 0.389s 0.410s 0.404s 2.249s 6.027s 🥉
N-Body Simulation 1.666s 2.120s 2.208s 2.386s 3.265s 🥈
Quicksort 0.215s 0.245s 0.213s 0.262s 0.226s #4
SQLite 0.347s 0.399s 0.427s 0.411s 🥈
Sieve of Eratosthenes 0.016s 0.028s 0.018s 0.038s 0.036s 🥉
String Manipulation 0.008s 0.046s 0.017s 0.035s 0.027s #5

CLI Tool Benchmarks

Benchmark ChadScript grep node xxd Place
Hex Dump 0.436s 0.943s 0.135s 🥈
Recursive Grep 0.019s 0.009s 0.094s 🥈

@cs01 cs01 changed the title un-skip switch-string-toplevel, add boolean[] test coverage fix native compiler class field initializers, add boolean[] tests Mar 20, 2026
…, fix getAllFields to avoid as ClassField on pushed elements
@cs01 cs01 merged commit 65067b6 into main Mar 20, 2026
13 checks passed
@cs01 cs01 deleted the feat/boolean-array branch March 20, 2026 21:57
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