-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround: Fix panic due to anonymous structs (#96)
Co-authored-by: Varun Gandhi <[email protected]>
- Loading branch information
1 parent
a5b080c
commit ba632a7
Showing
4 changed files
with
220 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Run SCIP-GO", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "cmd/scip-go", | ||
"cwd": "${input:path}", | ||
} | ||
], | ||
"inputs": [ | ||
{ | ||
"id": "path", | ||
"description": "Please enter the path to the project to index", | ||
"default": "", | ||
"type": "promptString" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
internal/testdata/snapshots/input/testdata/anonymous_structs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package testdata | ||
|
||
import "fmt" | ||
|
||
type TypeContainingAnonymousStructs struct { | ||
a, b struct { | ||
x int | ||
y string | ||
} | ||
c struct { | ||
X int | ||
Y string | ||
} | ||
} | ||
|
||
func funcContainingAnonymousStructs() { | ||
d := struct { | ||
x int | ||
y string | ||
}{ | ||
x: 1, | ||
y: "one", | ||
} | ||
|
||
var e struct { | ||
x int | ||
y string | ||
} | ||
|
||
e.x = 2 | ||
e.y = "two" | ||
|
||
var f TypeContainingAnonymousStructs | ||
f.a.x = 3 | ||
f.a.y = "three" | ||
f.b.x = 4 | ||
f.b.y = "four" | ||
f.c.X = 5 | ||
f.c.Y = "five" | ||
|
||
fmt.Printf("> %s, %s\n", d.x, d.y) | ||
fmt.Printf("> %s, %s\n", e.x, e.y) | ||
|
||
fmt.Printf("> %s, %s\n", f.a.x, f.a.y) | ||
fmt.Printf("> %s, %s\n", f.b.x, f.b.y) | ||
fmt.Printf("> %s, %s\n", f.c.X, f.c.Y) | ||
} |
137 changes: 137 additions & 0 deletions
137
internal/testdata/snapshots/output/testdata/anonymous_structs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
package testdata | ||
// ^^^^^^^^ reference 0.1.test `sg/testdata`/ | ||
|
||
import "fmt" | ||
// ^^^ reference github.com/golang/go/src go1.22 fmt/ | ||
|
||
type TypeContainingAnonymousStructs struct { | ||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition 0.1.test `sg/testdata`/TypeContainingAnonymousStructs# | ||
// documentation ```go | ||
// documentation ```go | ||
a, b struct { | ||
// ^ definition 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a. | ||
// documentation ```go | ||
// ^ definition 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b. | ||
// documentation ```go | ||
x int | ||
// ^ definition 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b.x. | ||
// documentation ```go | ||
y string | ||
// ^ definition 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b.y. | ||
// documentation ```go | ||
} | ||
c struct { | ||
// ^ definition 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#c. | ||
// documentation ```go | ||
X int | ||
// ^ definition 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#c.X. | ||
// documentation ```go | ||
Y string | ||
// ^ definition 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#c.Y. | ||
// documentation ```go | ||
} | ||
} | ||
|
||
func funcContainingAnonymousStructs() { | ||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition 0.1.test `sg/testdata`/funcContainingAnonymousStructs(). | ||
// documentation ```go | ||
d := struct { | ||
// ^ definition local 0 | ||
x int | ||
// ^ definition local 1 | ||
y string | ||
// ^ definition local 2 | ||
}{ | ||
x: 1, | ||
// ^ reference local 1 | ||
y: "one", | ||
// ^ reference local 2 | ||
} | ||
|
||
var e struct { | ||
// ^ definition local 3 | ||
x int | ||
// ^ definition local 4 | ||
y string | ||
// ^ definition local 5 | ||
} | ||
|
||
e.x = 2 | ||
// ^ reference local 3 | ||
// ^ reference local 4 | ||
e.y = "two" | ||
// ^ reference local 3 | ||
// ^ reference local 5 | ||
|
||
var f TypeContainingAnonymousStructs | ||
// ^ definition local 6 | ||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs# | ||
f.a.x = 3 | ||
// ^ reference local 6 | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a. | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b.x. | ||
f.a.y = "three" | ||
// ^ reference local 6 | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a. | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b.y. | ||
f.b.x = 4 | ||
// ^ reference local 6 | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b. | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b.x. | ||
f.b.y = "four" | ||
// ^ reference local 6 | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b. | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b.y. | ||
f.c.X = 5 | ||
// ^ reference local 6 | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#c. | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#c.X. | ||
f.c.Y = "five" | ||
// ^ reference local 6 | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#c. | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#c.Y. | ||
|
||
fmt.Printf("> %s, %s\n", d.x, d.y) | ||
// ^^^ reference github.com/golang/go/src go1.22 fmt/ | ||
// ^^^^^^ reference github.com/golang/go/src go1.22 fmt/Printf(). | ||
// ^ reference local 0 | ||
// ^ reference local 1 | ||
// ^ reference local 0 | ||
// ^ reference local 2 | ||
fmt.Printf("> %s, %s\n", e.x, e.y) | ||
// ^^^ reference github.com/golang/go/src go1.22 fmt/ | ||
// ^^^^^^ reference github.com/golang/go/src go1.22 fmt/Printf(). | ||
// ^ reference local 3 | ||
// ^ reference local 4 | ||
// ^ reference local 3 | ||
// ^ reference local 5 | ||
|
||
fmt.Printf("> %s, %s\n", f.a.x, f.a.y) | ||
// ^^^ reference github.com/golang/go/src go1.22 fmt/ | ||
// ^^^^^^ reference github.com/golang/go/src go1.22 fmt/Printf(). | ||
// ^ reference local 6 | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a. | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b.x. | ||
// ^ reference local 6 | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a. | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b.y. | ||
fmt.Printf("> %s, %s\n", f.b.x, f.b.y) | ||
// ^^^ reference github.com/golang/go/src go1.22 fmt/ | ||
// ^^^^^^ reference github.com/golang/go/src go1.22 fmt/Printf(). | ||
// ^ reference local 6 | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b. | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b.x. | ||
// ^ reference local 6 | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b. | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#a.b.y. | ||
fmt.Printf("> %s, %s\n", f.c.X, f.c.Y) | ||
// ^^^ reference github.com/golang/go/src go1.22 fmt/ | ||
// ^^^^^^ reference github.com/golang/go/src go1.22 fmt/Printf(). | ||
// ^ reference local 6 | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#c. | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#c.X. | ||
// ^ reference local 6 | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#c. | ||
// ^ reference 0.1.test `sg/testdata`/TypeContainingAnonymousStructs#c.Y. | ||
} | ||
|