Skip to content

Fix panic on directories with only _test.go files#256

Merged
jupblb merged 3 commits into
mainfrom
michal/test
May 15, 2026
Merged

Fix panic on directories with only _test.go files#256
jupblb merged 3 commits into
mainfrom
michal/test

Conversation

@jupblb
Copy link
Copy Markdown
Collaborator

@jupblb jupblb commented May 15, 2026

When a directory contains only *_test.go files belonging to an external '*_test' package, packages.Load returns a synthetic regular package whose Syntax slice is empty. indexVisitPackages then panicked on pkg.Syntax[0].

Fixes #255

jupblb added 2 commits May 15, 2026 22:36
When a directory contains only *_test.go files belonging to an external
'*_test' package, packages.Load (with Tests: true) returns a synthetic
regular package whose Syntax slice is empty. indexVisitPackages then
panicked on pkg.Syntax[0] while attaching package SymbolInformation.

Skip the package-symbol attachment when len(pkg.Syntax) == 0; the
external *_test package has its own non-empty entry and is processed
normally.

Fixes #255
A directory containing only *_test.go files (belonging to an external
*_test package) used to panic with 'index out of range [0] with length 0'
in indexVisitPackages. This snapshot exercises that scenario and pins
the resulting index for the package and its external test package.
The bug only requires a directory whose Go files all belong to an
external '*_test' package, leaving the synthetic regular package with
empty Syntax. A single pr256_test.go at the module root is enough; the
extra main.go and nested tests/comment/ subdirectory aren't needed.
@jupblb jupblb enabled auto-merge (squash) May 15, 2026 20:51
@jupblb jupblb requested review from eseliger and trly May 15, 2026 20:51
@jupblb jupblb merged commit d615e2d into main May 15, 2026
14 checks passed
@jupblb jupblb deleted the michal/test branch May 15, 2026 22:37
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.

scip-go v0.2.5 panics on a directory with only test files

2 participants