Skip to content

go: type alias alias_of is never registered across files — aliased receiver methods resolve by name coincidence only #2033

Description

@DeusData

Summary

CBMRegisteredType.alias_of (internal/cbm/lsp/type_registry.h:54) is followed correctly by the method-lookup chain (type_registry.c:675-701), but it is only ever set during the same-file AST scan. Cross-file, def-driven type registration never carries the alias target, so a type A = B declared in one file is invisible to method resolution on A in any other file of the same package.

Where

  • Only assignments of alias_of: internal/cbm/lsp/go_lsp.c:2233, :2243, :3065, :3075 — all inside the "Phase 1b: scan AST" blocks that walk the current file's tree.
  • The def-driven registration that ingests cross-file types (go_lsp.c ~2988-3010, guarded by cbm_label_is_type_like(d->label)) sets qualified_name, short_name, is_interface, embedded_types, method_names and field defs — never alias_of.
  • src/pipeline/pass_lsp_cross.c contains zero cbm_registry_add_type calls.

Corpus shape (kubernetes, staging/src/k8s.io/component-helpers/nodedeclaredfeatures/)

  • featureset.go:26type FeatureSet = bitmap (a true alias)
  • bitmap.go:38func (b bitmap) Set(i int)
  • framework.go:100reqs := f.NewFeatureSet()reqs.Set(i)

Three different files, one package. Today reqs.Set resolves — but via resolve_same_module hashing the flat QN pkg.Set (same_module, 0.9, cand=1), which is only right because exactly one Set exists in the package. It is a name hash, not type knowledge. With receiver-qualified QNs (#1913) the QN becomes pkg.bitmap.Set, the exact hash misses, and the edge is lost. b.Set in bitmap_test.go, where the receiver is typed in-file, resolves as lsp_type_dispatch 0.95.

Proposed fix

Carry alias_of through the def-driven cross-file registration: a Go def for type A = B records its aliased target so the shared registry can set rt.alias_of. Go semantics to keep straight: type A = B is an identity alias and inherits B's method set; type A B is a defined type and does not — only the former may be followed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparsing/qualityGraph extraction bugs, false positives, missing edges

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions