Skip to content

typeshelper: be even more thorough in resolving types#431

Draft
TvdW wants to merge 3 commits into
uber-go:mainfrom
TvdW:pointer-to-array-full
Draft

typeshelper: be even more thorough in resolving types#431
TvdW wants to merge 3 commits into
uber-go:mainfrom
TvdW:pointer-to-array-full

Conversation

@TvdW

@TvdW TvdW commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@TvdW
TvdW force-pushed the pointer-to-array-full branch from 3c97922 to 223e619 Compare July 2, 2026 19:10
@TvdW

TvdW commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@yuxincs it's a bigger change, and comes with a +5% diff on the golden tests... I've put this PR up for visibility into what a followup to #422 could look like, if you're interested (review individual commits, not the diff as a whole; I can put them up as separate stacked PRs if desired)

@TvdW
TvdW force-pushed the pointer-to-array-full branch from 223e619 to a7f305b Compare July 2, 2026 20:21
@TvdW TvdW changed the title typeshelper: resolve named types, aliases, and type parameters typeshelper: be even more thorough in resolving types Jul 2, 2026
TvdW added 3 commits July 7, 2026 22:14
…ypes

The x = append(x, ...) handling used the shallow IsSlice check, so
parameters of named slice types (or aliases) silently skipped
deep-assignment analysis. Use IsDeeplyType[*types.Slice] instead and drop
the now-unused IsSlice. For named slice types the diagnostic attaches to
the type's own annotation site rather than the parameter.
typeshelper.IsDeep is now a purely type-level predicate (fully resolving
named types, aliases, and type parameters). The nilaway-specific policy —
named deep types own their deep nilability at their type declaration
(nilable(A[])), everything else at the expression's location — moves to
the new annotation.DeepNilabilityIsLocal, next to
DeepNilabilityAsNamedType, and all location-site decisions go through it.

Also resolve aliases in DeepNilabilityAsNamedType: an alias of a named
deep type previously fell through to ProduceTriggerNever, losing deep
tracking entirely.
- UnwrapPtr sees through named pointer types and aliases (and is nil-safe).
- GetFuncSignature resolves via Underlying, so named function types work
  (its own doc example previously returned nil since only *types.Alias was
  handled); this gives calls of named func-typed values the usual
  error-return handling.
- TypeBarsNilness handles type parameters (a type parameter bars nil
  unless every term in its type set admits nil, per Go assignability) and
  aliases of type parameters.
- IsPointer scans the type set once and accepts mixed pointer-like unions
  such as ~*int | ~[]int.
- FuncIsOkReturning documents that requiring the literal bool (aliases
  included) is deliberate: a named boolean type signals the result means
  something other than the v, ok convention.

Resolving named function types exposed that NodeTriggersFuncErrRet treated
conversions to function types (f := MyFuncType(g)) as calls, panicking on
an operand-count mismatch; skip expressions whose Fun denotes a type.
@TvdW
TvdW force-pushed the pointer-to-array-full branch from a7f305b to 0324607 Compare July 7, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant