nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: elastic/go-sysinfo
Pull request #223 (2024-05-29 08:07:14)

Fix bug with NativeArchitecture ending in newline
This commit fixes a bug where HostInfo.NativeArchitecture ends in a newline and adds a test.

dliappis: @andrewkroh / @intxgo thanks for the quick reviews! Could one of you click "squash + merge" as I don't have such rights in this repo?
intxgo: @dliappis I also don't have the rights

Patch:
diff --git a/.changelog/223.txt b/.changelog/223.txt
new file mode 100644
index 0000000..c146df4
--- /dev/null
+++ b/.changelog/223.txt
@@ -0,0 +1,3 @@
+```release-note:bug
+linux: Remove newline from HostInfo.NativeArchitecture value.
+```
diff --git a/providers/linux/arch_linux.go b/providers/linux/arch_linux.go
index f1d807f..efb3010 100644
--- a/providers/linux/arch_linux.go
+++ b/providers/linux/arch_linux.go
@@ -81,5 +81,5 @@ func NativeArchitecture() (string, error) {
 	nativeArch := string(data)
 	nativeArch = strings.TrimRight(nativeArch, "\n")
 
-	return string(data), nil
+	return nativeArch, nil
 }


Test patch:
diff --git a/providers/linux/arch_linux_test.go b/providers/linux/arch_linux_test.go
index be46203..cae30a6 100644
--- a/providers/linux/arch_linux_test.go
+++ b/providers/linux/arch_linux_test.go
@@ -18,19 +18,24 @@
 package linux
 
 import (
+	"regexp"
 	"testing"
 
 	"github.com/stretchr/testify/assert"
 )
 
+var reNewline = regexp.MustCompile("^.*\n+$")
+
 func TestArchitecture(t *testing.T) {
 	a, err := Architecture()
 	assert.NoError(t, err)
 	assert.NotEmpty(t, a)
+	assert.NotRegexp(t, reNewline, a, "should not end in newlines")
 }
 
 func TestNativeArchitecture(t *testing.T) {
 	a, err := NativeArchitecture()
 	assert.NoError(t, err)
 	assert.NotEmpty(t, a)
+	assert.NotRegexp(t, reNewline, a, "should not end in newlines")
 }
Repository: elastic/go-ucfg
Pull request #163 (2020-04-20 08:56:54)

Fix min/max validator error messages
It seems the error messages for min/max validators are backwards. Say I have a field with `validate:"min=1, max=5"`.

Supplying a value of 0, I get the error message:

```
Error processing configuration: requires value < 1 accessing 'field.name'
```

I would expect that to say `...value >= 1...`

Supplying a value of 6, I get the error message:

```
Error processing configuration: requires value > 5 accessing 'field.name'
```

I would expect that to say `...value <= 5...`


Patch:
diff --git a/validator.go b/validator.go
index 8a72abf..2fda344 100644
--- a/validator.go
+++ b/validator.go
@@ -287,7 +287,7 @@ func validateMin(v interface{}, param string) error {
 		}
 
 		if min > d {
-			return fmt.Errorf("requires duration < %v", param)
+			return fmt.Errorf("requires duration >= %v", param)
 		}
 		return nil
 	}
@@ -322,7 +322,7 @@ func validateMin(v interface{}, param string) error {
 		return nil
 	}
 
-	return fmt.Errorf("requires value < %v", param)
+	return fmt.Errorf("requires value >= %v", param)
 }
 
 func validateMax(v interface{}, param string) error {
@@ -337,7 +337,7 @@ func validateMax(v interface{}, param string) error {
 		}
 
 		if max < d {
-			return fmt.Errorf("requires duration > %v", param)
+			return fmt.Errorf("requires duration <= %v", param)
 		}
 		return nil
 	}
@@ -372,7 +372,7 @@ func validateMax(v interface{}, param string) error {
 		return nil
 	}
 
-	return fmt.Errorf("requires value > %v", param)
+	return fmt.Errorf("requires value <= %v", param)
 }
 
 // validateRequired implements the `required` validation tag.


Test patch:
diff --git a/initializer_test.go b/initializer_test.go
index 5f25558..995a8b2 100644
--- a/initializer_test.go
+++ b/initializer_test.go
@@ -72,6 +72,15 @@ func (n *ptrNestedStructInitializer) InitDefaults() {
 	n.O = 20
 }
 
+type structWithArrayInitializer struct {
+	O int
+	A []structInitializer
+}
+
+func (s *structWithArrayInitializer) InitDefaults() {
+	s.O = 10
+}
+
 func TestInitDefaultsPrimitive(t *testing.T) {
 	c, _ := NewFrom(map[string]interface{}{})
 
@@ -233,3 +242,23 @@ func TestInitDefaultsPtrNestedEmpty(t *testing.T) {
 	assert.Nil(t, r.S.P)
 	assert.Equal(t, 20, r.S.O)
 }
+
+func TestInitDefaultsStructWithArray(t *testing.T) {
+	c, _ := NewFrom(map[string]interface{}{
+		"a": []map[string]interface{}{
+			{
+				"i": 5,
+			},
+		},
+	})
+
+	r := structWithArrayInitializer{}
+	err := c.Unpack(&r)
+	assert.NoError(t, err)
+	assert.Equal(t, 10, r.O)
+	assert.Len(t, r.A, 1)
+	for _, e := range r.A {
+		assert.Equal(t, 5, e.I)
+		assert.Equal(t, 10, e.J)
+	}
+}
Repository: kythe/kythe
Pull request #5438 (2022-11-09 17:39:13)

fix: passthrough nil Spans without work


Patch:
diff --git a/kythe/go/util/span/span.go b/kythe/go/util/span/span.go
index 799b2ee48..6351836c7 100644
--- a/kythe/go/util/span/span.go
+++ b/kythe/go/util/span/span.go
@@ -202,7 +202,7 @@ func (p *Patcher) PatchSpan(s *cpb.Span) (span *cpb.Span, exists bool) {
 	spanEnd := s.GetEnd().GetByteOffset()
 	if spanStart > spanEnd {
 		return nil, false
-	} else if p == nil {
+	} else if p == nil || s == nil {
 		return s, true
 	}
 


Test patch:
diff --git a/kythe/go/util/span/span_test.go b/kythe/go/util/span/span_test.go
index 6b9dd5718..c62108348 100644
--- a/kythe/go/util/span/span_test.go
+++ b/kythe/go/util/span/span_test.go
@@ -177,10 +177,12 @@ func TestPatchSpan(t *testing.T) {
 		oldSpans: []*cpb.Span{
 			sp(p(0, 1, 0), p(4, 1, 4)),
 			sp(p(13, 1, 13), p(17, 1, 17)),
+			nil,
 		},
 		newSpans: []*cpb.Span{
 			sp(p(0, 1, 0), p(4, 1, 4)),
 			sp(p(21, 1, 21), p(25, 1, 25)),
+			nil,
 		},
 	}, {
 		oldText: "line one\nline two\nline three\nline four\n",
@@ -281,7 +283,11 @@ func TestPatchSpan(t *testing.T) {
 				t.Run(strconv.Itoa(i), func(t *testing.T) {
 					found, exists := p.PatchSpan(s)
 
-					if ns := test.newSpans[i]; ns == nil && exists {
+					if ns := test.newSpans[i]; s == nil && ns == nil {
+						if found != nil || !exists {
+							t.Errorf("Expected nil span to exist as nil span in new text; received %s %v", found, exists)
+						}
+					} else if ns == nil && exists {
 						t.Errorf("Expected span not to exist in new text; received %s", found)
 					} else if ns != nil && !exists {
 						t.Errorf("Expected span %s to exist in new text as %s; did not exist", s, ns)
Repository: kythe/kythe
Pull request #5471 (2022-12-07 21:08:20)

fix(rust_indexer): set root when creating vname for reference

wcalandro: > if not too onerous, a test of this would be great

Is it possible to the vname of an edge?
wcalandro: > if not too onerous, a test of this would be great

I'm not sure of a way to properly test this since the `defines/binding` anchor has the right root, it's just that the vname for the target anchor of the edge doesn't.
shahms: > > if not too onerous, a test of this would be great
> 
> I'm not sure of a way to properly test this since the `defines/binding` anchor has the right root, it's just that the vname for the target anchor of the edge doesn't.

https://www.kythe.io/docs/kythe-verifier.html#_explicit_unification

Something like:
```
//- @SomeAnchor ref AnotherNode=vname(_, _, "root", _, _)
....
```

Patch:
diff --git a/kythe/rust/indexer/src/indexer/analyzers.rs b/kythe/rust/indexer/src/indexer/analyzers.rs
index 63ea3c36b..1fa7f0e62 100644
--- a/kythe/rust/indexer/src/indexer/analyzers.rs
+++ b/kythe/rust/indexer/src/indexer/analyzers.rs
@@ -782,6 +782,7 @@ impl<'a, 'b> CrateAnalyzer<'a, 'b> {
                 )?;
                 continue;
             }
+            reference_vname.set_root(file_vname.unwrap().get_root().to_string());
             reference_vname.set_path(file_vname.unwrap().get_path().to_string());
 
             let byte_span = self.get_byte_span(&ref_id, span)?;
@@ -855,6 +856,7 @@ impl<'a, 'b> CrateAnalyzer<'a, 'b> {
                 )?;
                 continue;
             }
+            reference_vname.set_root(file_vname.unwrap().get_root().to_string());
             reference_vname.set_path(file_vname.unwrap().get_path().to_string());
 
             let byte_span = self.get_byte_span(&reference.ref_id, span)?;


Test patch:
diff --git a/kythe/rust/indexer/testdata/out_dir/generated.rs b/kythe/rust/indexer/testdata/out_dir/generated.rs
index d1ca113a6..1da3d6bad 100644
--- a/kythe/rust/indexer/testdata/out_dir/generated.rs
+++ b/kythe/rust/indexer/testdata/out_dir/generated.rs
@@ -4,3 +4,8 @@
 pub fn print_hello_world() {
     println!("Hello, world!");
 }
+
+pub fn other_function() {
+    //- @print_hello_world=vname(_, _, "bazel-out/bin", _, _) ref FnPrint
+    print_hello_world();
+}
Repository: kythe/kythe
Pull request #5513 (2023-02-04 00:46:53)

fix(typescript): emit code blocks for interface properties and fix TODO
1. Add marked sources for interface properties. They were skipped originally, probably an oversight.

2. Don't emit TODO when building signature of a node and going through a node that claims to have a name (it has 'name' property) but the actual value is 'undefined'. For example IndexedSignature has 'name' but it's undefined.

This should significantly reduce TODO noise in indexer logs.


Patch:
diff --git a/kythe/typescript/indexer.ts b/kythe/typescript/indexer.ts
index 2d40397bb..68db5702d 100644
--- a/kythe/typescript/indexer.ts
+++ b/kythe/typescript/indexer.ts
@@ -560,9 +560,9 @@ class StandardIndexerContext implements IndexerHost {
           // TODO: namespace {}, etc.
 
           // If the node is actually some subtype that has a 'name' attribute
-          // it's likely this function should have handled it.  Dynamically
-          // probe for this case and warn if we missed one.
-          if ('name' in (node as any)) {
+          // and it's not empty it's likely this function should have handled
+          // it. Dynamically probe for this case and warn if we missed one.
+          if ((node as any).name != null) {
             todo(
                 this.sourceRoot, node,
                 `scopedSignature: ${ts.SyntaxKind[node.kind]} ` +
@@ -1651,7 +1651,8 @@ class Visitor {
     if (vname) {
       if (ts.isVariableDeclaration(decl) || ts.isPropertyAssignment(decl) ||
           ts.isPropertyDeclaration(decl) || ts.isBindingElement(decl) ||
-          ts.isShorthandPropertyAssignment(decl)) {
+          ts.isShorthandPropertyAssignment(decl) ||
+          ts.isPropertySignature(decl)) {
         this.emitDeclarationCode(decl, vname);
       } else {
         todo(this.sourceRoot, decl, 'Emit variable delaration code');
@@ -1690,7 +1691,8 @@ class Visitor {
    */
   emitDeclarationCode(
       decl: ts.VariableDeclaration|ts.PropertyAssignment|
-      ts.PropertyDeclaration|ts.BindingElement|ts.ShorthandPropertyAssignment,
+      ts.PropertyDeclaration|ts.BindingElement|ts.ShorthandPropertyAssignment|
+      ts.PropertySignature,
       declVName: VName) {
     const codeParts: JSONMarkedSource[] = [];
     const initializerList = decl.parent;


Test patch:
diff --git a/kythe/typescript/testdata/marked_source/property.ts b/kythe/typescript/testdata/marked_source/property.ts
index 76766f750..4450798f3 100644
--- a/kythe/typescript/testdata/marked_source/property.ts
+++ b/kythe/typescript/testdata/marked_source/property.ts
@@ -49,3 +49,17 @@ let b = {
   //- BPropInit.pre_text "1"
   bprop: 1,
 };
+
+interface C {
+  //- @cprop defines/binding CProp
+  //- CProp code CPropCode
+  //- CPropCode child.0 CPropContext
+  //- CPropContext.pre_text "(property)"
+  //- CPropCode child.1 CPropSpace
+  //- CPropSpace.pre_text " "
+  //- CPropCode child.2 CPropName
+  //- CPropName.pre_text "cprop"
+  //- CPropCode child.3 CPropTy
+  //- CPropTy.post_text "string"
+  cprop: string;
+}
Repository: kythe/kythe
Pull request #5533 (2023-03-10 23:45:38)

feat(typescript_indexer): clean up unused options and rename allFiles to rootFiles for clarity


Patch:
diff --git a/kythe/typescript/indexer.ts b/kythe/typescript/indexer.ts
index 981e9a36c..a8cbbcf94 100644
--- a/kythe/typescript/indexer.ts
+++ b/kythe/typescript/indexer.ts
@@ -42,8 +42,12 @@ export interface CompilationUnit {
   /** Files to index. */
   srcs: string[];
 
-  /** List of all files, both srcs and deps. */
-  allFiles: string[];
+  /**
+   * List of files from which TS compiler will start type checking. It should include srcs files + file that provide
+   * global types, that are not imported from srcs files. All other dep files must be loaded following imports
+   * and by IndexingOptions.readFile function.
+   */
+  rootFiles: string[];
 }
 
 /**
@@ -132,22 +136,10 @@ export interface IndexerHost {
    * See moduleName() for more details.
    */
   moduleName(path: string): string;
-  /**
-   * Paths to index.
-   * TODO: Remove completely and instead pass paths explicitly
-   * as inputs to methods.
-   */
-  paths: string[];
   /**
    * TypeScript program.
-   * TODO: migrate usages to options.program
    */
   program: ts.Program;
-  /**
-   * Strategy to emit Kythe entries by.
-   * TODO: migrate usages to options.emit
-   */
-  emit(obj: JSONFact|JSONEdge): void;
 }
 
 /**
@@ -370,17 +362,11 @@ class StandardIndexerContext implements IndexerHost {
 
   private typeChecker: ts.TypeChecker;
 
-  public readonly emit: (obj: JSONFact|JSONEdge) => void;
-  public readonly paths: string[];
-
-
   constructor(
     public readonly program: ts.Program,
     public readonly compilationUnit: CompilationUnit,
     public readonly options: IndexingOptions,
   ) {
-    this.paths = compilationUnit.srcs;
-    this.emit = options.emit;
     this.sourceRoot = this.program.getCompilerOptions().rootDir || process.cwd();
     let rootDirs = this.program.getCompilerOptions().rootDirs || [this.sourceRoot];
     rootDirs = rootDirs.map(d => d + '/');
@@ -2690,7 +2676,7 @@ class Visitor {
  */
 export function index(compilationUnit: CompilationUnit, options: IndexingOptions): ts.Diagnostic[] {
   const program = ts.createProgram({
-    rootNames: compilationUnit.allFiles,
+    rootNames: compilationUnit.rootFiles,
     options: options.compilerOptions,
     host: options.compilerHost,
   });
@@ -2775,7 +2761,7 @@ function main(argv: string[]) {
   const compilationUnit: CompilationUnit = {
     srcs: inPaths,
     rootVName,
-    allFiles: inPaths,
+    rootFiles: inPaths,
     fileVNames: new Map(),
   };
   index(compilationUnit, {


Test patch:
diff --git a/kythe/typescript/test.ts b/kythe/typescript/test.ts
index eedf25657..d50c3c47b 100644
--- a/kythe/typescript/test.ts
+++ b/kythe/typescript/test.ts
@@ -120,7 +120,7 @@ function verify(
       rootVName,
       fileVNames,
       srcs: testFiles,
-      allFiles: testFiles,
+      rootFiles: testFiles,
     };
     indexer.index(compilationUnit, {
       compilerOptions: options,
Repository: kythe/kythe
Pull request #5558 (2023-03-30 15:45:52)

test: add test for large file patching


Patch:
diff --git a/external.bzl b/external.bzl
index dbf82f209..b7752eba5 100644
--- a/external.bzl
+++ b/external.bzl
@@ -778,8 +778,8 @@ def _go_dependencies():
         patches = [
             "@io_kythe//third_party/go:add_export_license.patch",
         ],
-        sum = "h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=",
-        version = "v1.2.0",
+        sum = "h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=",
+        version = "v1.3.1",
     )
     go_repository(
         name = "com_github_sourcegraph_go_langserver",
diff --git a/go.mod b/go.mod
index 12ce5e68c..bf19da11b 100644
--- a/go.mod
+++ b/go.mod
@@ -18,7 +18,7 @@ require (
 	github.com/jmhodges/levigo v1.0.0
 	github.com/minio/highwayhash v1.0.2
 	github.com/pkg/errors v0.9.1
-	github.com/sergi/go-diff v1.2.0
+	github.com/sergi/go-diff v1.3.1
 	github.com/sourcegraph/go-langserver v2.0.0+incompatible
 	github.com/sourcegraph/jsonrpc2 v0.1.0
 	github.com/syndtr/goleveldb v1.0.0
diff --git a/go.sum b/go.sum
index 3dc68e6b1..0ff69e08b 100644
--- a/go.sum
+++ b/go.sum
@@ -211,8 +211,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
 github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
 github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
-github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
-github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
+github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
+github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
 github.com/sourcegraph/go-langserver v2.0.0+incompatible h1:lj2sRU7ZMIkW372IDVGb6fE8VAY4c/EMsiDzrB9vmiU=
 github.com/sourcegraph/go-langserver v2.0.0+incompatible/go.mod h1:bBMjfpzEHd6ijPRoQ7f+knFfw+e8R+W158/MsqAy77c=
 github.com/sourcegraph/jsonrpc2 v0.1.0 h1:ohJHjZ+PcaLxDUjqk2NC3tIGsVa5bXThe1ZheSXOjuk=


Test patch:
diff --git a/kythe/go/util/span/span_test.go b/kythe/go/util/span/span_test.go
index 8bdcda265..dfadefd19 100644
--- a/kythe/go/util/span/span_test.go
+++ b/kythe/go/util/span/span_test.go
@@ -369,6 +369,29 @@ func TestMarshal(t *testing.T) {
 	}
 }
 
+func TestLargeDiff(t *testing.T) {
+	var before, after string
+	for i := 0; i < 60; i++ {
+		before += fmt.Sprintf("%d\n", i)
+		after += fmt.Sprintf("%d\n", i/2)
+	}
+
+	patcher, err := NewPatcher([]byte(before), []byte(after))
+	testutil.Fatalf(t, "NewPatcher: %v", err)
+
+	s := sp(p(26, 12, 1), p(28, 12, 3))
+	expected := sp(p(55, 25, 1), p(57, 25, 3))
+
+	found, exists := patcher.PatchSpan(s)
+	if !exists {
+		t.Fatal("Patched span does not exist")
+	}
+
+	if diff := compare.ProtoDiff(expected, found); diff != "" {
+		t.Errorf("(-expected; +found)\n%s", diff)
+	}
+}
+
 type span struct{ Start, End int32 }
 
 func (s span) String() string { return fmt.Sprintf("(%d, %d]", s.Start, s.End) }
Repository: kythe/kythe
Pull request #5561 (2023-03-31 21:06:11)

feat(typescript): emit code nodes for tsx attributes
This avoids noisy TODOs currently emitted for TSX files. Overall I'm not sure if there is value in outputting nodes for DOM attributes in tsx files. But given it was already implemented - I just fixed what already exists.


Patch:
diff --git a/kythe/typescript/indexer.ts b/kythe/typescript/indexer.ts
index ddfa0250e..218dd391a 100644
--- a/kythe/typescript/indexer.ts
+++ b/kythe/typescript/indexer.ts
@@ -1752,7 +1752,7 @@ class Visitor {
       if (ts.isVariableDeclaration(decl) || ts.isPropertyAssignment(decl) ||
           ts.isPropertyDeclaration(decl) || ts.isBindingElement(decl) ||
           ts.isShorthandPropertyAssignment(decl) ||
-          ts.isPropertySignature(decl)) {
+          ts.isPropertySignature(decl) || ts.isJsxAttribute(decl)) {
         this.emitDeclarationCode(decl, vname);
       } else {
         todo(this.sourceRoot, decl, 'Emit variable delaration code');
@@ -1792,7 +1792,7 @@ class Visitor {
   emitDeclarationCode(
       decl: ts.VariableDeclaration|ts.PropertyAssignment|
       ts.PropertyDeclaration|ts.BindingElement|ts.ShorthandPropertyAssignment|
-      ts.PropertySignature,
+      ts.PropertySignature|ts.JsxAttribute,
       declVName: VName) {
     const codeParts: JSONMarkedSource[] = [];
     const initializerList = decl.parent;


Test patch:
diff --git a/kythe/typescript/testdata/tsx.tsx b/kythe/typescript/testdata/tsx.tsx
index 3d5261ab8..aa282b3f9 100644
--- a/kythe/typescript/testdata/tsx.tsx
+++ b/kythe/typescript/testdata/tsx.tsx
@@ -6,9 +6,22 @@ function render() {
   //- @#0"value" defines/binding Value
   const value = 'value';
   return (
-    //- @"attr" defines/binding _Attr
+    //- @"attr" defines/binding Attr
     //- @"value" ref Value
-    //- @+4"src" defines/binding _Src
+    //- Attr code AttrCode
+    //- AttrCode child.0 AttrContext
+    //- AttrContext.pre_text "(property)"
+    //- AttrCode child.1 AttrSpace
+    //- AttrSpace.pre_text " "
+    //- AttrCode child.2 AttrName
+    //- AttrName.pre_text "attr"
+    //- AttrCode child.3 AttrTy
+    //- AttrTy.post_text "string"
+    //- AttrCode child.4 AttrEq
+    //- AttrEq.pre_text " = "
+    //- AttrCode child.5 AttrInit
+    //- AttrInit.pre_text "{value}"
+    //- @+4"src" defines/binding _Src1
     //- @+3"value" ref Value
     //- @+3"src" defines/binding _Src2
     <div attr={value}>
Repository: kythe/kythe
Pull request #5568 (2023-04-04 22:01:00)

fix(go_indexer): don't strip extensions from import paths


Patch:
diff --git a/kythe/go/extractors/govname/govname.go b/kythe/go/extractors/govname/govname.go
index 9e31d56f5..dae146feb 100644
--- a/kythe/go/extractors/govname/govname.go
+++ b/kythe/go/extractors/govname/govname.go
@@ -22,6 +22,7 @@ import (
 	"go/build"
 	"log"
 	"path/filepath"
+	"regexp"
 	"strings"
 
 	"golang.org/x/tools/go/vcs"
@@ -212,6 +213,8 @@ func IsStandardLibrary(v *spb.VName) bool {
 	return v != nil && (v.Language == "go" || v.Language == "") && v.Corpus == GolangCorpus
 }
 
+var archiveExt = regexp.MustCompile(`\.[xa]$`)
+
 // ImportPath returns the putative Go import path corresponding to v.  The
 // resulting string corresponds to the string literal appearing in source at the
 // import site for the package so named.
@@ -220,7 +223,7 @@ func ImportPath(v *spb.VName, goRoot string) string {
 		return v.Path
 	}
 
-	trimmed := strings.TrimSuffix(v.Path, filepath.Ext(v.Path))
+	trimmed := archiveExt.ReplaceAllString(v.Path, "")
 	if tail, ok := rootRelative(goRoot, trimmed); ok {
 		// Paths under a nonempty GOROOT are treated as if they were standard
 		// library packages even if they are not labelled as "golang.org", so
diff --git a/kythe/go/indexer/BUILD b/kythe/go/indexer/BUILD
index 6e8c1024f..04fe8b740 100644
--- a/kythe/go/indexer/BUILD
+++ b/kythe/go/indexer/BUILD
@@ -264,11 +264,19 @@ go_indexer_test(
     has_marked_source = True,
 )
 
+go_indexer_test(
+    name = "dep.v2",
+    srcs = ["testdata/dep.v2.go"],
+)
+
 go_indexer_test(
     name = "dependent_test",
     srcs = ["testdata/dependent.go"],
     has_marked_source = True,
-    deps = [":types_test"],
+    deps = [
+        ":dep.v2",
+        ":types_test",
+    ],
 )
 
 go_indexer_test(


Test patch:
diff --git a/kythe/go/indexer/testdata/dep.v2.go b/kythe/go/indexer/testdata/dep.v2.go
new file mode 100644
index 000000000..1db93f420
--- /dev/null
+++ b/kythe/go/indexer/testdata/dep.v2.go
@@ -0,0 +1,5 @@
+package dep // import "kythe/go/indexer/dep.v2"
+
+// - @F defines/binding F
+// - F.node/kind function
+func F() {}
diff --git a/kythe/go/indexer/testdata/dependent.go b/kythe/go/indexer/testdata/dependent.go
index 14d2b6f83..257e96236 100644
--- a/kythe/go/indexer/testdata/dependent.go
+++ b/kythe/go/indexer/testdata/dependent.go
@@ -3,6 +3,7 @@ package dependent
 import (
 	"fmt"
 
+	dep "kythe/go/indexer/dep.v2"
 	types "kythe/go/indexer/types_test"
 )
 
@@ -25,3 +26,8 @@ func f(
 	//- @String ref String
 	a.String()
 }
+
+func g() {
+	//- @F ref F
+	dep.F()
+}