Skip to content

fix boolean class fields and map/filter on class field arrays#474

Merged
cs01 merged 1 commit intomainfrom
class-object-array-boolean-fixes
Mar 19, 2026
Merged

fix boolean class fields and map/filter on class field arrays#474
cs01 merged 1 commit intomainfrom
class-object-array-boolean-fixes

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 19, 2026

Summary

  • Boolean class fields now work correctly — field access no longer reads wrong offsets due to i1/double type mismatch in GEP calculations
  • .map()/.filter() on class instance arrays stored as class fields now correctly resolve element types in callbacks, so field access in callbacks returns real values instead of garbage

Changes

  • member.ts: fix classFieldToLlvm() to return double for boolean (matching actual class struct layout)
  • iteration.ts: add resolveObjectArrayElementType() helper that handles member_access expressions (e.g. this.items) in addition to simple variables, used by filter/forEach/reduce/map
  • New test fixtures for both fixes

Test plan

  • class-boolean-field.ts — boolean field access on class instances
  • class-field-array-map-filter.ts — filter/map on this.items inside class methods
  • Full npm run verify passes (all 758 tests + 3-stage self-hosting)

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown
Contributor

Benchmark Results (Linux x86-64)

Benchmark C ChadScript Go Node Bun Place
Binary Trees 1.344s 1.400s 2.968s 1.359s 1.176s #4
Cold Start 0.6ms 0.6ms 1.1ms 21.9ms 7.5ms 🥇
Fibonacci 0.724s 1.144s 1.429s 2.841s 1.836s 🥈
File I/O 0.071s 0.073s 0.073s 0.228s 0.157s 🥈
JSON Parse/Stringify 0.003s 0.005s 0.017s 0.014s 0.006s 🥈
Matrix Multiply 0.406s 0.648s 0.436s 0.438s 0.462s #5
Monte Carlo Pi 0.400s 0.374s 0.405s 1.473s 6.470s 🥇
N-Body Simulation 1.424s 1.596s 1.947s 2.283s 2.836s 🥈
Quicksort 0.170s 0.262s 0.184s 0.249s 0.204s #5
SQLite 0.317s 0.365s 0.451s 0.350s 🥉
Sieve of Eratosthenes 0.029s 0.040s 0.035s 0.056s 0.052s 🥉
String Manipulation 0.008s 0.038s 0.016s 0.036s 0.027s #5

@cs01 cs01 merged commit 4d8c7fa into main Mar 19, 2026
13 checks passed
@cs01 cs01 deleted the class-object-array-boolean-fixes branch April 24, 2026 20:53
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