Repository navigation
v0.7.10.7
v0.7.10.7 — extended args (PosOnly / KwOnly / *args / **kwargs) in funcbody
Date: 2026-04-30
Spec: notes/Spec/1500/1565_gocopy_v07107_extended_args.md
Roadmap: notes/Spec/1500/1558_gocopy_v0710x_release_roadmap.md
v0.7.10.7 opens visitFuncBodyDef to function signatures that use
positional-only, keyword-only, *args, and **kwargs parameters.
The visitor still gates out defaults and parameter annotations
(those land at v0.7.10.8 / v0.7.10.10). Body emit shape is
unchanged — the work is purely in the function unit's metadata
(co_argcount, co_posonlyargcount, co_kwonlyargcount,
co_flags, co_varnames, co_localspluskinds).
Bringing fixture 020 (def f(a, b, /, c, d, *args, e, f, **kwargs))
online surfaced two latent symtable bugs that no shipped fixture
exercised before:
bindArgsappended params in the AST source order
(PosOnly + Args + Vararg + KwOnly + Kwarg). CPython's
co_varnamesputs KwOnly BEFORE Vararg/Kwarg. Reordered to
match.LocalsPlusKindsreturnedLocalsKindArg(FastLocal | FastArg
= 0x26) for every param. CPython differentiates by arg kind:
posonly = 0x22, regular = 0x26, kwonly = 0x24,
*args= 0x2a,**kwargs= 0x2c. The fix derives the
arg-kind bits from each param's slot position inParams,
using thePosOnlyCount/ArgCount/KwOnlyCount/
HasVararg/HasKwargalready on Scope.
Added
tests/fixtures/funcbody/016_args_vararg.py—
def f(*args): return args. PinsCO_VARARGS,ArgCount=0,
single-slot LocalsPlusNames.tests/fixtures/funcbody/017_args_kwarg.py—
def f(**kwargs): return kwargs. PinsCO_VARKEYWORDS.tests/fixtures/funcbody/018_args_posonly.py—
def f(a, /, b): return a. PinsPosOnlyArgCount=1,
ArgCount=2.tests/fixtures/funcbody/019_args_kwonly.py—
def f(a, *, b): return b. PinsKwOnlyArgCount=1,
ArgCount=1.tests/fixtures/funcbody/020_args_full.py—
def f(a, b, /, c, d, *args, e, f, **kwargs): return args. Pins
the full extended layout. Exercises both the bindArgs reorder and
the LocalsPlusKinds per-position kind bits.
Changed
compiler/codegen/visit_funcbody_stmt.go— gates loosened to
accept PosOnly / KwOnly / Vararg / Kwarg. Defaults and non-nil
KwOnlyDef still reject. Validation extended over all named-param
slots (name length 1..15, col ≤ 255, no annotation). Slot-count
cap remains 15.assemble.Optionspopulated:
ArgCount = PosOnly + Args,PosOnlyArgCount,KwOnlyArgCount,
flags includeCO_VARARGS/CO_VARKEYWORDSwhen present.compiler/symtable/build.go::bindArgs— append order corrected
toPosOnly + Args + KwOnly + Vararg + Kwarg.compiler/symtable/scope.go::LocalsPlusKinds— per-position
arg-kind derivation. Backwards-compatible: every pre-v0.7.10.7
fixture used regular positional args only, which still map to
LocalsKindArg(0x26).CHANGELOG.md— v0.7.10.7 entry added.
Tests
- Oracle (
bash tests/run.sh): 265/265 fixtures byte-identical
(was 260/260). - Visitor parity (
go test ./compiler/ -run TestVisitorParity):
byte-identical=224 not-implemented=41 mismatched=0 errored=0
(was 219/41/0/0; the 5 new fixtures all land in the byte-identical
bucket). - All existing tests stay green.
Out of scope (deferred)
- Defaults / KwOnlyDef — v0.7.10.8 (needs
codegen_default_arguments). - Parameter annotations — v0.7.10.10 (decorators+annotations bundle).
- Type params — same release as annotations.