Skip to content

Commit

Permalink
fix: Propagate errors when creating repro SCIP index (part 2) (#297)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
varungandhi-src authored Dec 17, 2024
1 parent 23b1855 commit 94484d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cmd/scip/tests/reprolang/bindings/go/repro/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,17 @@ func Index(
}

// Phase 2: resolve names for definitions
var allErrs error
for _, dependency := range reproDependencies {
dependency.enterGlobalDefinitions(ctx)
if err := dependency.enterGlobalDefinitions(ctx); err != nil {
allErrs = errors.CombineErrors(allErrs, errors.Wrapf(err, "package: %v", dependency.Package))
}
}
for _, file := range reproSources {
file.enterDefinitions(ctx)
}

// Phase 3: resolve names for references
var allErrs error
for _, file := range reproSources {
if err := file.resolveReferences(ctx); err != nil {
allErrs = errors.CombineErrors(allErrs, errors.Wrapf(err, "file %q", file.Source.AbsolutePath))
Expand Down
5 changes: 4 additions & 1 deletion cmd/scip/tests/reprolang/bindings/go/repro/namer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ import (

// enterGlobalDefinitions inserts the names of the global symbols that are defined in this
// dependency into the provided global scope.
func (d *reproDependency) enterGlobalDefinitions(context *reproContext) {
func (d *reproDependency) enterGlobalDefinitions(context *reproContext) error {
var errs error
enter := func(file *reproSourceFile, name *identifier) {
if name.isLocalSymbol() {
return
}
symbol := newGlobalSymbol(d.Package, file, name)
parsedSymbol, err := scip.ParseSymbol(symbol)
if err != nil {
errs = errors.CombineErrors(errs, errors.Wrapf(err, "file: %q", file.Source.AbsolutePath))
return
}
newName := newGlobalName(context.pkg, parsedSymbol)
Expand All @@ -30,6 +32,7 @@ func (d *reproDependency) enterGlobalDefinitions(context *reproContext) {
enter(file, relationship.name)
}
}
return errs
}

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

0 comments on commit 94484d9

Please sign in to comment.