Skip to content

[codegen] annotate call/method-call/ternary with class/interface result types#665

Closed
cs01 wants to merge 1 commit intomainfrom
gate-loosen-call
Closed

[codegen] annotate call/method-call/ternary with class/interface result types#665
cs01 wants to merge 1 commit intomainfrom
gate-loosen-call

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Apr 22, 2026

Before

`foo()`, `obj.m()`, and `a ? b : c` expressions weren't cached in typeOf even when their result type was a concrete class/interface.

After

All three kinds are cached when the resolved result type is class/interface.

Description

Bundled steps 5-7 of #658 into one PR since they share the mechanical pattern (delegate to `resolveExpressionTypeRich`, filter by same class/interface source-kind as steps 1-4). With this, all seven candidate kinds from the audit are wired:

  1. variable ([codegen] annotate variable reads bound to class-typed parameters #660 merged, [codegen] widen variable annotation to interface-typed parameters #661 merged)
  2. member_access ([codegen] annotate member-access expressions with class/interface types #662)
  3. binary/unary ([codegen] annotate binary/unary expressions with class/interface result types #663)
  4. index_access ([codegen] annotate index-access expressions with class/interface element types #664)
  5. call
  6. method_call
  7. conditional (ternary)

Verification

  • `npm run verify` (Stage 0 + Stage 1 + Stage 2 self-hosting + full test suite): PASSED

Refs #658.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 22, 2026

Benchmark Results (Linux x86-64)

Benchmark C ChadScript Go Node Place
Cold Start 0.8ms 0.6ms 1.0ms 24.2ms 🥇
Fibonacci 0.724s 0.721s 1.428s 2.835s 🥇
Hash Map Lookup 0.093s 0.062s 0.089s 0.117s 🥇
Monte Carlo Pi 0.400s 0.381s 0.405s 1.473s 🥇
Regex Match 0.013s 0.004s 0.020s 0.004s 🥇
JSON Parse/Stringify 0.031s 0.044s 0.166s 0.123s 🥈
Matrix Multiply 0.396s 0.415s 0.421s 0.424s 🥈
N-Body Simulation 1.451s 1.849s 1.949s 2.275s 🥈
SQLite 0.046s 0.328s 0.464s 0.411s 🥈
Binary Trees 1.244s 1.292s 2.896s 1.215s 🥉
File I/O 0.072s 0.073s 0.070s 0.214s 🥉
Quicksort 0.169s 0.215s 0.182s 0.247s 🥉
Sieve of Eratosthenes 0.027s 0.038s 0.034s 0.053s 🥉
String Manipulation 0.008s 0.016s 0.016s 0.035s 🥉

CLI Tool Benchmarks

Benchmark ChadScript grep node xxd Place
Hex Dump 0.469s 0.929s 0.068s 🥈
Recursive Grep 0.012s 0.007s 0.101s 🥈

@cs01 cs01 force-pushed the gate-loosen-call branch from c4db9dd to 7e26047 Compare April 22, 2026 18:26
@cs01
Copy link
Copy Markdown
Owner Author

cs01 commented Apr 22, 2026

Closing — same x86-64 Stage 0→1 self-hosting segfault as #662 (reverted in #666). See #663 close comment.

@cs01 cs01 closed this Apr 22, 2026
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