feat: inspect generic structs (approximate layout + disclaimer)#17
Merged
Conversation
…sclaimer
Inspect mode previously skipped generic types (no concrete layout until
instantiated). Instead, instantiate each type parameter with a representative
type — its constraint's core type (e.g. ~int -> int), or interface{} when
unbounded (any/comparable/unions) — and show the resulting layout, prefixed with
a disclaimer noting the assumption. The header renders the type-parameter names
(type Generic[T] struct {).
- common.Layout gains TypeParams and Note; ui.renderLayout prints the note above
the declaration and the params in the header.
- layout.resolveStruct/representativeType do the instantiation (types.Instantiate
with validate=false); non-struct and non-instantiable types are still skipped.
- README gains an "Inspecting generic types" explainer + example; AGENTS/caveats
updated.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## devel #17 +/- ##
==========================================
+ Coverage 83.07% 83.83% +0.76%
==========================================
Files 10 10
Lines 573 662 +89
==========================================
+ Hits 476 555 +79
- Misses 56 67 +11
+ Partials 41 40 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…me marker Inspect no longer substitutes a type parameter into the field declaration (`Value any`). The field now reads as written (`Value T`) and the assumption that drove its measured size moves to an aligned inline marker (`-- assume T=any`), shown only on fields whose size depends on a type parameter — directly or through a composite / nested generic (`map[K]V` → `K=any, V=any`, `Inner[V]` → `V=any`). - common.LayoutField gains Assume. - layout sizes the instantiated struct but renders types + markers from the origin struct; fieldAssume/collectTypeParams walk the origin field type for referenced params (pointers, slices, arrays, chans, maps, named generics, structs, signatures). - ui aligns the marker past the widest comment. - Tests for one/two type params and an indirect nested-generic member; README and AGENTS updated. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Inspect mode used to silently skip generic types. Now it shows a best-effort
layout with a clear disclaimer.
Behavior
Each type parameter is replaced by a representative type — its constraint's core
type (
~int→int), orinterface{}when unbounded (any/comparable/unions).The disclaimer line + the
[T]in the header make the approximation explicit.Changes
common.LayoutgainsTypeParams+Note;ui.renderLayoutrenders them.layout.resolveStruct/representativeTypeinstantiate viatypes.Instantiate(validate=false); non-struct / non-instantiable types are still skipped.
AGENTS.md and the generic caveat updated.
task cigreen; new layout/ui tests cover the any/core-type/non-struct paths.