go: parse.sx — func type expressions (anonymous params) + 9 tests [nothing]
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 20s

Adds Go func-type parsing to gp-parse-type:
  func()                  →  (list :ty-func () ())
  func() int              →  (list :ty-func () [int])
  func(int, string)       →  (list :ty-func [int string] ())
  func(int) string        →  (list :ty-func [int] [string])
  func() (int, error)     →  (list :ty-func () [int error])

gp-parse-func-type-params handles the param list inside (...);
gp-parse-func-type-results dispatches between bare single-return,
multi-return parenthesised list, or no return.

Anonymous-only — named params (`func(a int, b string)`) require a
different shape and are mainly needed for func DECLARATIONS, not for
pure func-type expressions in type position. Variadic ('...T')
deferred.

Covers nested cases: func returning func, chan of func, func with
pointer/slice operands.

parse 90/90, total 219/219.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-27 08:06:53 +00:00
parent 8ba66e0dc9
commit 9acdbcb8d8
5 changed files with 147 additions and 8 deletions

View File

@@ -176,8 +176,9 @@ Progress-log line → push `origin/loops/go`.
`*T` / `**T`); full type grammar still pending below.
- [/] Type expressions: **slice `[]T`, array `[N]T`, map `map[K]V`, chan
`chan T` / `chan<- T` / `<-chan T`, pointer `*T`, named `T`,
qualified `pkg.T`** all done — kit has no type primitives.
func / struct / interface / generics deferred.
qualified `pkg.T`, func `func(...) ...` (anonymous params, single
or multi return)** all done — kit has no type primitives.
struct / interface / variadic / named-params / generics deferred.
- [ ] Composite literals: `T{...}`, `[]T{...}`, `map[K]V{...}`,
`struct{...}{...}`.
- [ ] Declarations: `package`, `import`, `var`, `const`, `type`, `func`
@@ -188,7 +189,7 @@ Progress-log line → push `origin/loops/go`.
- [ ] End-to-end: hello-world, fibonacci, FizzBuzz, goroutine ping-pong,
struct + method.
- **Acceptance:** parse/ suite at 80+ tests. **Acceptance bar crossed:
81/81.** Remaining sub-items (func/struct/interface types, composite
90/90.** Remaining sub-items (struct/interface types, composite
literals, decls, stmts, e2e) still keep Phase 2 open ⬜.
### Phase 3 — Bidirectional type checker, MVP (`lib/go/types.sx`) ⬜
@@ -491,6 +492,16 @@ 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 2 cont.: func-type expressions. `func()`,
`func() int`, `func(int, string)`, `func(int) string`,
`func() (int, error)`. AST shape `(list :ty-func PARAMS RESULTS)`
where both are lists of type nodes. Results parsing reuses param
parser for the multi-return `(T, T, ...)` case. Anonymous-only
params for now — named params (`func(a int, b string)`) need a
different shape and are required mainly for func DECLARATIONS not
pure func-type expressions. Variadic deferred. Covers nested
func-as-return and chan-of-func. +9 tests, parse 90/90, total 219/219.
`[nothing]` — pure Go parser; type AST proposals already in Blockers.
- 2026-05-27 — Phase 2 cont.: type expressions — slice `[]T`, array
`[N]T`, map `map[K]V`, chan in all three directions (`chan T`,
`chan<- T`, `<-chan T`). `gp-parse-type` now dispatches on