Skip to content

fix: .map()/.filter() on class arrays without type annotation#400

Merged
cs01 merged 1 commit intomainfrom
fix/class-array-literal-type
Mar 14, 2026
Merged

fix: .map()/.filter() on class arrays without type annotation#400
cs01 merged 1 commit intomainfrom
fix/class-array-literal-type

Conversation

@cs01
Copy link
Owner

@cs01 cs01 commented Mar 14, 2026

Summary

  • [new Item("a"), new Item("b")] without an explicit Item[] type annotation was misclassified as a number array (%Array*) instead of an object array (%ObjectArray*)
  • This caused .map() and .filter() callbacks to receive class instance pointers as double values, producing wrong results (empty strings, wrong counts)
  • Now the type inferrer checks array literal elements for new expressions that resolve to known classes, and falls back to recursive element type resolution for other non-primitive types

Test plan

  • New test fixture arrays/class-array-map-filter.ts.map() extracts field, .filter() filters by field value
  • All existing tests pass
  • Self-hosting Stage 1 passes

🤖 Generated with Claude Code

@cs01 cs01 merged commit d28e8aa into main Mar 14, 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