mkcgo: restore 1-arg slice attribute support#13
Conversation
The slice attribute handler was changed to require exactly 2 arguments in 920ecfb, but the Attrs.String() serializer still handles Len=="" correctly. This broke downstream consumers (go-crypto-darwin) that use slice(ptr) for fixed-size buffers with no explicit length parameter (e.g. IV, tag, key buffers with known sizes). Restore support for 1 or 2 arguments to match the serializer behavior.
There was a problem hiding this comment.
Pull request overview
This PR restores mkcgo’s slice attribute parsing to accept either 1 or 2 arguments, aligning the parser with the existing Attrs.String() serializer behavior and unblocking downstream headers that use slice(ptr) for fixed-size buffers.
Changes:
- Update the
sliceattribute handler to accept 1 or 2 arguments (instead of requiring exactly 2). - Update parse-error test expectations to match the new error message for invalid
slicearity.
Show a summary per file
| File | Description |
|---|---|
| internal/mkcgo/mkcgo.go | Adjusts slice attribute arity validation and parsing to support slice(ptr) and slice(ptr,len). |
| internal/mkcgo/mkcgo_test.go | Updates expected error messages for invalid slice attribute argument counts. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
Benchmark Results✅ ❌
|
The slice attribute handler was changed to require exactly 2 arguments in 920ecfb, but the
Attrs.String()serializer still handlesLen==""correctly. This broke downstream consumers (go-crypto-darwin) that useslice(ptr)for fixed-size buffers with no explicit length parameter (e.g. IV, tag, key buffers with known sizes).Restore support for 1 or 2 arguments to match the serializer behavior.
Fixes parsing errors like:
for declarations such as: