go: types.sx — call type-checking + 8 tests; recursive funcs now type [nothing]
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 36s

Phase 3 cont. The expression-synth :app dispatch is now bifurcated:

  * go-is-binop-call? — head is :var with an operator name AND 2 args
    AND the operator is in one of the binop tables. Short-circuits to
    go-synth-binop as before.
  * Everything else routes to go-synth-call.

go-synth-call:
  1. Synth the callee. Must produce a (list :ty-func PARAMS RESULTS).
     Otherwise → (:type-error :not-callable TYPE).
  2. Arity-check args vs params. Mismatch → (:type-error :arity-mismatch).
  3. go-check-args-against: each arg assignable to corresponding param
     (untyped-constant flow works — `f(42)` accepts the untyped int
     into an int param).
  4. Result by count:
       0 results → (list :ty-void)
       1 result  → that result directly
       N results → (list :ty-tuple TYPES)   for multi-return

The recursive case lights up: go-check-func-decl binds the function
in its own body's ctx before checking. So:

  func fib(n int) int { return fib(n) + fib(n) }

now type-checks because `fib` resolves inside the body, synth-call
sees its `:ty-func` and verifies the recursive call. Multi-return
functions destructure into `:ty-tuple` which short-decl will need to
consume next iteration.

types 55/55, total 360/360.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-27 20:56:10 +00:00
parent 9f4c6787e4
commit 5b4a8be689
5 changed files with 173 additions and 15 deletions

View File

@@ -239,14 +239,17 @@ Progress-log line → push `origin/loops/go`.
signature, assignments verify RHS assignable to LHS). The function
itself is bound in the body's ctx so recursion will work once
call-checking lands. Signature-only (no body) just binds.
- [ ] Call type-checking (synth callee, check args against param types,
synth result).
- [x] Call type-checking. `go-synth-call`: synth callee → expect
`:ty-func`, arity-check, check each arg assignable to param,
then return type by result count (0 → `:ty-void`, 1 → that type,
N → `:ty-tuple`). Recursive calls now type-check because the func
is bound in the body's ctx. Untyped-constant args flow through.
- [ ] Composite type element checking (slice / map / chan).
- [ ] Interface satisfaction (structural match against method sets).
- [ ] Short variable declaration `:=` (synth RHS into LHS bindings).
- Defer: generics (Phase 7), full conversion rules, type assertions,
type switches.
- **Acceptance:** types/ suite at 60+ tests. Current: 47/47. Chisel note
- **Acceptance:** types/ suite at 60+ tests. Current: 55/55. Chisel note
`shapes-static-types-bidirectional` — sister-plan design diary is the
cross-language record.
@@ -547,6 +550,20 @@ Minimal repro: see `lib/go/lex.sx#gl-oct-digit?` and `#gl-match-op`.
_Newest first. Append one dated entry per commit._
- 2026-05-27 — Phase 3 cont.: call type-checking. `go-synth-call`
synthesises the callee's type, asserts it's a `:ty-func`, arity-
checks args, then `go-check-args-against` runs each arg through
`go-check` against the corresponding param type (untyped-constant
flow works). Result: `:ty-void` for 0-result funcs, the result type
for 1-result, `(list :ty-tuple TYPES)` for multi-return. The
`:app` dispatch in `go-synth` now routes via `go-is-binop-call?`
(operator name + 2 args + op in the binop tables) — binops short-
circuit; everything else goes through the call path. **Recursive
functions now type-check** because the func is bound in its own
body's ctx by `go-check-func-decl`. +8 tests, types 55/55, total
360/360. `[nothing]` — Go-side composition on top of established
primitives; no new kit-relevant shapes (call semantics are uniform
across statically-typed guests).
- 2026-05-27 — Phase 3 cont.: function-declaration checking +
statement-level dispatch. `go-check-func-decl` binds the function in
the outer ctx (so the body can see itself), extends the body's ctx