go: types.sx — func-decl + stmt-level dispatch + 7 tests [nothing]
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 31s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 31s
Phase 3 cont. Adds:
* go-check-func-decl — binds the function in the outer ctx (recursive
self-reference will work once call-checking lands), extends the
body's ctx with each :field param group via go-ctx-extend-field
(the binding-group shape's *third* consumer in the type checker;
five total across parser+typer when counted with struct fields,
var-decls, const-decls, func params, method receivers).
* go-check-stmt — dispatches on :return / :assign / :var-decl /
:const-decl / :short-decl / :type-decl / :block; falls back to
go-synth for expression statements.
* go-check-block — threads ctx through stmts so that decls inside
the block extend the ctx for subsequent stmts.
* go-check-return-list — each return expr assignable to the
corresponding declared result type; mismatch counts are typed.
* go-check-assign / go-check-assign-pairs — RHS assignable to LHS
synthesised type, count mismatch typed.
* Helpers: go-decl-params-to-ty-list (flattens :field NAMES TYPE to
a flat list of N types), go-extend-with-params (folds extend-field
over a param-group list), go-repeat-ty.
Coverage tests:
func empty() {} → ok
func add(x, y int) int { return x + y } → ok
func bad() int { return "hi" } → typed error
func sig(x int) int → signature-only binds
func sumsq(x, y int) int { return x*x + y*y } → params visible
func two() int { var x int = 1; var y int = 2; → nested decl
return x + y }
func g() int { var x int; x = 5; return x } → assign verified
types 47/47, total 352/352.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -234,8 +234,11 @@ Progress-log line → push `origin/loops/go`.
|
||||
the extended context or a `:type-error`. Untyped synthesized types
|
||||
get their default-type (`untyped-int → int`, `untyped-float →
|
||||
float64`, etc.) when bound in inferred-type decls.
|
||||
- [ ] Function declaration: extend ctx with params via `:field` group,
|
||||
check body, verify return-list types match signature.
|
||||
- [x] Function declaration: extends ctx with each `:field` param group,
|
||||
checks block body (decls thread through, returns verify against
|
||||
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).
|
||||
- [ ] Composite type element checking (slice / map / chan).
|
||||
@@ -243,7 +246,7 @@ Progress-log line → push `origin/loops/go`.
|
||||
- [ ] 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: 40/40. Chisel note
|
||||
- **Acceptance:** types/ suite at 60+ tests. Current: 47/47. Chisel note
|
||||
`shapes-static-types-bidirectional` — sister-plan design diary is the
|
||||
cross-language record.
|
||||
|
||||
@@ -544,6 +547,19 @@ 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.: 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
|
||||
with each `:field` param group via `go-ctx-extend-field` (the
|
||||
binding-group shape's third consumer in the type checker — now
|
||||
five total across parser+typer combined), then runs `go-check-block`
|
||||
through every statement. `go-check-stmt` dispatches on `:return`,
|
||||
`:assign`, `:var-decl`/`:const-decl`/`:short-decl`/`:type-decl`,
|
||||
`:block`, falling back to `go-synth` for expression statements.
|
||||
Return-list and assign-pair count mismatches are typed errors. +7
|
||||
tests, types 47/47, total 352/352. `[nothing]` — pure Go-side
|
||||
composition; the kit-relevant insights are already in the sister-
|
||||
plan diary.
|
||||
- 2026-05-27 — Phase 3 cont.: declaration checking — `var`/`const`/`type`
|
||||
+ short-decl `:=`. `go-check-decl` returns the extended context (or a
|
||||
`:type-error`). New helpers: `go-default-type` (untyped-int → int,
|
||||
|
||||
Reference in New Issue
Block a user