Skip to content

Commit 94484d9

Browse files
fix: Propagate errors when creating repro SCIP index (part 2) (#297)
When trying to enter definitions, we were incorrectly dropping symbol parsing errors. This can lead to failures downstream when attempting Find references on a SCIP index.
1 parent 23b1855 commit 94484d9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

cmd/scip/tests/reprolang/bindings/go/repro/indexer.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,17 @@ func Index(
6262
}
6363

6464
// Phase 2: resolve names for definitions
65+
var allErrs error
6566
for _, dependency := range reproDependencies {
66-
dependency.enterGlobalDefinitions(ctx)
67+
if err := dependency.enterGlobalDefinitions(ctx); err != nil {
68+
allErrs = errors.CombineErrors(allErrs, errors.Wrapf(err, "package: %v", dependency.Package))
69+
}
6770
}
6871
for _, file := range reproSources {
6972
file.enterDefinitions(ctx)
7073
}
7174

7275
// Phase 3: resolve names for references
73-
var allErrs error
7476
for _, file := range reproSources {
7577
if err := file.resolveReferences(ctx); err != nil {
7678
allErrs = errors.CombineErrors(allErrs, errors.Wrapf(err, "file %q", file.Source.AbsolutePath))

cmd/scip/tests/reprolang/bindings/go/repro/namer.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ import (
99

1010
// enterGlobalDefinitions inserts the names of the global symbols that are defined in this
1111
// dependency into the provided global scope.
12-
func (d *reproDependency) enterGlobalDefinitions(context *reproContext) {
12+
func (d *reproDependency) enterGlobalDefinitions(context *reproContext) error {
13+
var errs error
1314
enter := func(file *reproSourceFile, name *identifier) {
1415
if name.isLocalSymbol() {
1516
return
1617
}
1718
symbol := newGlobalSymbol(d.Package, file, name)
1819
parsedSymbol, err := scip.ParseSymbol(symbol)
1920
if err != nil {
21+
errs = errors.CombineErrors(errs, errors.Wrapf(err, "file: %q", file.Source.AbsolutePath))
2022
return
2123
}
2224
newName := newGlobalName(context.pkg, parsedSymbol)
@@ -30,6 +32,7 @@ func (d *reproDependency) enterGlobalDefinitions(context *reproContext) {
3032
enter(file, relationship.name)
3133
}
3234
}
35+
return errs
3336
}
3437

3538
// enterDefinitions inserts the names of the definitions into the appropriate scope (local symbols go into the local scope).

0 commit comments

Comments
 (0)