Skip to content

feat: console.log/JSON.stringify for all types, for...of on strings#204

Merged
cs01 merged 9 commits intomainfrom
feat/console-log-map-set
Mar 11, 2026
Merged

feat: console.log/JSON.stringify for all types, for...of on strings#204
cs01 merged 9 commits intomainfrom
feat/console-log-map-set

Conversation

@cs01
Copy link
Owner

@cs01 cs01 commented Mar 11, 2026

Summary

  • console.log now works on Maps, Sets, class instances, and interfaces (was [object Object] or empty)
  • JSON.stringify now works on Maps (Map<string, *>) and class instances with correct boolean handling
  • for...of on strings now works (for (const ch of str)) instead of compile error
  • JSON.stringify on Sets gives helpful compile error with suggestion to convert to array

Details

  • Map printing uses open-addressing hash table iteration (skip null slots)
  • Set printing uses linear iteration
  • Class instance fields: boolean stored as double in struct, converted via fcmp une
  • String for-of: allocates 2-byte GC buffer per character, null-terminated
  • Interface console.log delegates to JSON.stringify

Test plan

  • console-log-map.ts — Map(2) { a => 1, b => 2 }
  • console-log-set.ts — Set(3) { 10, 20, 30 }
  • console-log-class.ts — Point {"x":10.0,"y":20.0}
  • console-log-interface.ts — {"x":10.0,"y":20.0}
  • json-stringify-unsupported-map.ts — Map stringify works
  • json-stringify-class.ts — class instance with boolean fields
  • string-for-of.ts — iterate, concat, break
  • Self-hosting passes (Stage 0 + Stage 1)
  • All 470 tests pass

🤖 Generated with Claude Code

cs01 and others added 7 commits March 10, 2026 19:40
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…f [object Object]

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… with suggestion

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… set error

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cs01 cs01 changed the title feat: console.log prints map and set contents feat: console.log/JSON.stringify for all types, for...of on strings Mar 11, 2026
cs01 and others added 2 commits March 10, 2026 20:37
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…object/class variables

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cs01 cs01 merged commit b003988 into main Mar 11, 2026
12 checks passed
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