[tools] gopls/internal/test/marker: add optional error to typedef marker

5 views
Skip to first unread message

Hongxiang Jiang (Gerrit)

unread,
Dec 10, 2025, 12:52:56 AM (7 days ago) Dec 10
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Hongxiang Jiang has uploaded the change for review

Commit message

gopls/internal/test/marker: add optional error to typedef marker

The typedef marker now accept optional input parameter error to
verify if the typedef returns an expected error from gopls.

Also migrate regression test for golang/go#60544 from integration
to marker test.

For golang/go#76723
Change-Id: Id5076268fb0458720693a30868e44e2cf0952395

Change diff

diff --git a/gopls/internal/test/integration/misc/definition_test.go b/gopls/internal/test/integration/misc/definition_test.go
index efe7df8..f7024d1 100644
--- a/gopls/internal/test/integration/misc/definition_test.go
+++ b/gopls/internal/test/integration/misc/definition_test.go
@@ -321,37 +321,6 @@
}
}

-func TestGoToTypeDefinition_Issue60544(t *testing.T) {
- const mod = `
--- go.mod --
-module mod.com
-
-go 1.19
--- main.go --
-package main
-
-func F[T comparable]() {}
-`
-
- Run(t, mod, func(t *testing.T, env *Env) {
- env.OpenFile("main.go")
-
- // TypeDefinition of comparable should not panic.
- loc := env.RegexpSearch("main.go", "comparable")
- locs, err := env.Editor.TypeDefinitions(env.Ctx, loc) // doesn't panic
- if err != nil {
- t.Fatal(err)
- }
-
- // For extra credit, check the actual location.
- got := fmt.Sprint(locs)
- wantSubstr := "builtin.go"
- if !strings.Contains(got, wantSubstr) {
- t.Errorf("TypeDefinitions('comparable') = %v, want substring %q", got, wantSubstr)
- }
- })
-}
-
// Test for golang/go#47825.
func TestImportTestVariant(t *testing.T) {
const mod = `
diff --git a/gopls/internal/test/marker/doc.go b/gopls/internal/test/marker/doc.go
index 44f2a63..040cb4f 100644
--- a/gopls/internal/test/marker/doc.go
+++ b/gopls/internal/test/marker/doc.go
@@ -310,8 +310,10 @@
request at the given location, and asserts that the result includes
exactly one token with the given token type and modifier string.

- - typedef(src, want ...location): performs a textDocument/typeDefinition request
- at the src location, and checks that the results equals want.
+ - typedef(src, want ...location, err=stringMatcher): performs a
+ textDocument/typeDefinition request at the src location, and checks that the
+ results equals want. If err is set, the implementation query must fail with
+ the expected error.

- workspacesymbol(query, golden): makes a workspace/symbol request for the
given query, formats the response with one symbol per line, and compares
diff --git a/gopls/internal/test/marker/marker_test.go b/gopls/internal/test/marker/marker_test.go
index c5ff7a2..f07229f 100644
--- a/gopls/internal/test/marker/marker_test.go
+++ b/gopls/internal/test/marker/marker_test.go
@@ -618,7 +618,7 @@
"quickfixerr": actionMarkerFunc(quickfixErrMarker),
"symbol": actionMarkerFunc(symbolMarker),
"token": actionMarkerFunc(tokenMarker),
- "typedef": actionMarkerFunc(typedefMarker),
+ "typedef": actionMarkerFunc(typedefMarker, "err"),
"workspacesymbol": actionMarkerFunc(workspaceSymbolMarker),
"mcptool": actionMarkerFunc(mcpToolMarker, "location", "output"),
}
@@ -1715,11 +1715,18 @@
}
}

+// typedefMarker implements the @typedef marker.
func typedefMarker(mark marker, loc protocol.Location, want ...protocol.Location) {
+ wantErr := namedArgFunc(mark, "err", convertStringMatcher, stringMatcher{})
+
env := mark.run.env
got, err := env.Editor.TypeDefinitions(env.Ctx, loc)
- if err != nil {
- mark.errorf("typeDefinition request failed: %v", err)
+ if err != nil && wantErr.empty() {
+ mark.errorf("typeDefinition at %s failed: %v", loc, err)
+ return
+ }
+ if !wantErr.empty() {
+ wantErr.checkErr(mark, err)
return
}

diff --git a/gopls/internal/test/marker/testdata/typedef/issue60544.txt b/gopls/internal/test/marker/testdata/typedef/issue60544.txt
new file mode 100644
index 0000000..cc5ab00
--- /dev/null
+++ b/gopls/internal/test/marker/testdata/typedef/issue60544.txt
@@ -0,0 +1,10 @@
+Regression test for golang/go#60544.
+
+-- go.mod --
+module mod.com
+
+go 1.19
+-- main.go --
+package main
+
+func F[T comparable]() {}//@typedef(re"comparable()", BUILTIN)
diff --git a/gopls/internal/test/marker/testdata/typedef/typedef.txt b/gopls/internal/test/marker/testdata/typedef/typedef.txt
index 559abab..b9737ca 100644
--- a/gopls/internal/test/marker/testdata/typedef/typedef.txt
+++ b/gopls/internal/test/marker/testdata/typedef/typedef.txt
@@ -40,20 +40,34 @@
_ = s.x.xx.field2 //@typedef(re"field2()", Int)
}

+// type def returns function return types' location.
+
func F1() Int { return 0 }
-func F2() (Int, float64) { return 0, 0 }
-func F3() (Struct, int, bool, error) { return Struct{}, 0, false, nil }
-func F4() (**int, Int, bool, *error) { return nil, 0, false, nil }
-func F5() (int, float64, error, Struct) { return 0, 0, nil, Struct{} }
-func F6() (int, float64, ***Struct, error) { return 0, 0, nil, nil }
+func F2() error { return nil }
+func F3() (Int, float64) { return 0, 0 }
+func F4() (Int, error) { return 0, nil }
+func F5() (Struct, int, bool, error) { return Struct{}, 0, false, nil }
+func F6() (**int, Int, bool, *error) { return nil, 0, false, nil }
+func F7() (int, float64, error, Struct) { return 0, 0, nil, Struct{} }
+func F8() (int, float64, ***Struct, error) { return 0, 0, nil, nil }
+
+// type def returns error.
+
+func E1() {}
+func E2() (int, bool) { return 0, true }

func _() {
F1() //@typedef(re"F1()", Int)
- F2() //@typedef(re"F2()", Int)
- F3() //@typedef(re"F3()", BUILTIN, Struct)
- F4() //@typedef(re"F4()", BUILTIN, Int)
- F5() //@typedef(re"F5()", BUILTIN, Struct)
- F6() //@typedef(re"F6()", BUILTIN, Struct)
+ F2() //@typedef(re"F2()", BUILTIN)
+ F3() //@typedef(re"F3()", Int)
+ F4() //@typedef(re"F4()", Int, BUILTIN)
+ F5() //@typedef(re"F5()", Struct, BUILTIN)
+ F6() //@typedef(re"F6()", Int, BUILTIN)
+ F7() //@typedef(re"F7()", Struct, BUILTIN)
+ F8() //@typedef(re"F8()", Struct, BUILTIN)
+
+ E1() //@typedef(re"E1()", err="cannot find type name(s)")
+ E2() //@typedef(re"E2()", err="cannot find type name(s)")

f := func() Int { return 0 }
f() //@typedef(re"f()", Int)

Change information

Files:
  • M gopls/internal/test/integration/misc/definition_test.go
  • M gopls/internal/test/marker/doc.go
  • M gopls/internal/test/marker/marker_test.go
  • A gopls/internal/test/marker/testdata/typedef/issue60544.txt
  • M gopls/internal/test/marker/testdata/typedef/typedef.txt
Change size: M
Delta: 5 files changed, 48 insertions(+), 46 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Id5076268fb0458720693a30868e44e2cf0952395
Gerrit-Change-Number: 728880
Gerrit-PatchSet: 1
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
unsatisfied_requirement
satisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Dec 10, 2025, 12:53:56 AM (7 days ago) Dec 10
to goph...@pubsubhelper.golang.org, Alan Donovan, Madeline Kalil, golang-co...@googlegroups.com
Attention needed from Alan Donovan and Madeline Kalil

Hongxiang Jiang voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Alan Donovan
  • Madeline Kalil
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Id5076268fb0458720693a30868e44e2cf0952395
Gerrit-Change-Number: 728880
Gerrit-PatchSet: 1
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-Attention: Madeline Kalil <mka...@google.com>
Gerrit-Attention: Alan Donovan <adon...@google.com>
Gerrit-Comment-Date: Wed, 10 Dec 2025 05:53:49 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Madeline Kalil (Gerrit)

unread,
Dec 11, 2025, 4:57:27 PM (5 days ago) Dec 11
to Hongxiang Jiang, goph...@pubsubhelper.golang.org, Go LUCI, Alan Donovan, golang-co...@googlegroups.com
Attention needed from Alan Donovan and Hongxiang Jiang

Madeline Kalil voted and added 2 comments

Votes added by Madeline Kalil

Code-Review+2

2 comments

File gopls/internal/test/marker/doc.go
Line 315, Patchset 1 (Latest): results equals want. If err is set, the implementation query must fail with
Madeline Kalil . unresolved

type definition

File gopls/internal/test/marker/testdata/typedef/typedef.txt
Line 49, Patchset 1 (Latest):func F5() (Struct, int, bool, error) { return Struct{}, 0, false, nil }
Madeline Kalil . unresolved

General question: why can you jump to definition on basic types like int, bool, but can't do a type def query on these? Shouldn't they jump to the same place, in the same way that type def and normal def on "error" jump to the same place?

Open in Gerrit

Related details

Attention is currently required from:
  • Alan Donovan
  • Hongxiang Jiang
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Id5076268fb0458720693a30868e44e2cf0952395
Gerrit-Change-Number: 728880
Gerrit-PatchSet: 1
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Attention: Alan Donovan <adon...@google.com>
Gerrit-Comment-Date: Thu, 11 Dec 2025 21:57:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Dec 14, 2025, 9:57:08 PM (2 days ago) Dec 14
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Alan Donovan and Hongxiang Jiang

Hongxiang Jiang uploaded new patchset

Hongxiang Jiang uploaded patch set #2 to this change.
Following approvals got outdated and were removed:
  • TryBots-Pass: LUCI-TryBot-Result-1 by Go LUCI
Open in Gerrit

Related details

Attention is currently required from:
  • Alan Donovan
  • Hongxiang Jiang
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Id5076268fb0458720693a30868e44e2cf0952395
Gerrit-Change-Number: 728880
Gerrit-PatchSet: 2
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Dec 14, 2025, 9:57:18 PM (2 days ago) Dec 14
to goph...@pubsubhelper.golang.org, Madeline Kalil, Go LUCI, Alan Donovan, golang-co...@googlegroups.com
Attention needed from Alan Donovan

Hongxiang Jiang voted and added 2 comments

Votes added by Hongxiang Jiang

Commit-Queue+1

2 comments

File gopls/internal/test/marker/doc.go
Line 315, Patchset 1: results equals want. If err is set, the implementation query must fail with
Madeline Kalil . resolved

type definition

Hongxiang Jiang

Oops. Done.

File gopls/internal/test/marker/testdata/typedef/typedef.txt
Line 49, Patchset 1:func F5() (Struct, int, bool, error) { return Struct{}, 0, false, nil }
Madeline Kalil . resolved

General question: why can you jump to definition on basic types like int, bool, but can't do a type def query on these? Shouldn't they jump to the same place, in the same way that type def and normal def on "error" jump to the same place?

Hongxiang Jiang

I think this is more of an existing behavior. Gopls ignores basic types like this...

I think people think it's less useful to provide type def info for these built-in types...

I'm happy to change the behavior, we can discuss this offline.

Open in Gerrit

Related details

Attention is currently required from:
  • Alan Donovan
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Id5076268fb0458720693a30868e44e2cf0952395
Gerrit-Change-Number: 728880
Gerrit-PatchSet: 2
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-Attention: Alan Donovan <adon...@google.com>
Gerrit-Comment-Date: Mon, 15 Dec 2025 02:57:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Madeline Kalil <mka...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Alan Donovan (Gerrit)

unread,
Dec 14, 2025, 10:20:41 PM (2 days ago) Dec 14
to Hongxiang Jiang, goph...@pubsubhelper.golang.org, Go LUCI, Madeline Kalil, golang-co...@googlegroups.com
Attention needed from Hongxiang Jiang

Alan Donovan added 1 comment

File gopls/internal/test/marker/testdata/typedef/typedef.txt
Line 49, Patchset 1:func F5() (Struct, int, bool, error) { return Struct{}, 0, false, nil }
Madeline Kalil . resolved

General question: why can you jump to definition on basic types like int, bool, but can't do a type def query on these? Shouldn't they jump to the same place, in the same way that type def and normal def on "error" jump to the same place?

Hongxiang Jiang

I think this is more of an existing behavior. Gopls ignores basic types like this...

I think people think it's less useful to provide type def info for these built-in types...

I'm happy to change the behavior, we can discuss this offline.

Alan Donovan

I think this is more of an existing behavior. Gopls ignores basic types like this...
I think people think it's less useful to provide type def info for these built-in types...

This is historically correct, but perhaps built-in types were rejected because TypeDefinition could (until now) report only a single type, so ignoring built-in types helped us locate the one type of interest. But if we can now report on all the named types in (say) the result tuple of a function call, then I see no reason not to treat them all consistently. We should of course check the ergonomics in VS Code (and I can check in Emacs+eglot) before committing.

Open in Gerrit

Related details

Attention is currently required from:
  • Hongxiang Jiang
Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: tools
    Gerrit-Branch: master
    Gerrit-Change-Id: Id5076268fb0458720693a30868e44e2cf0952395
    Gerrit-Change-Number: 728880
    Gerrit-PatchSet: 2
    Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
    Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
    Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
    Gerrit-Comment-Date: Mon, 15 Dec 2025 03:20:35 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Madeline Kalil <mka...@google.com>
    Comment-In-Reply-To: Hongxiang Jiang <hxj...@golang.org>
    satisfied_requirement
    open
    diffy

    Hongxiang Jiang (Gerrit)

    unread,
    Dec 14, 2025, 10:30:13 PM (2 days ago) Dec 14
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Hongxiang Jiang and Madeline Kalil

    Hongxiang Jiang uploaded new patchset

    Hongxiang Jiang uploaded patch set #3 to this change.
    Following approvals got outdated and were removed:
    • Code-Review: +2 by Madeline Kalil
    • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Hongxiang Jiang
    • Madeline Kalil
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: tools
    Gerrit-Branch: master
    Gerrit-Change-Id: Id5076268fb0458720693a30868e44e2cf0952395
    Gerrit-Change-Number: 728880
    Gerrit-PatchSet: 3
    Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
    Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
    Gerrit-Attention: Madeline Kalil <mka...@google.com>
    Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Hongxiang Jiang (Gerrit)

    unread,
    Dec 14, 2025, 10:34:54 PM (2 days ago) Dec 14
    to goph...@pubsubhelper.golang.org, Go LUCI, Madeline Kalil, Alan Donovan, golang-co...@googlegroups.com
    Attention needed from Alan Donovan and Madeline Kalil

    Hongxiang Jiang voted and added 1 comment

    Votes added by Hongxiang Jiang

    Commit-Queue+1

    1 comment

    File gopls/internal/test/marker/testdata/typedef/typedef.txt
    Line 49, Patchset 1:func F5() (Struct, int, bool, error) { return Struct{}, 0, false, nil }
    Madeline Kalil . resolved

    General question: why can you jump to definition on basic types like int, bool, but can't do a type def query on these? Shouldn't they jump to the same place, in the same way that type def and normal def on "error" jump to the same place?

    Hongxiang Jiang

    I think this is more of an existing behavior. Gopls ignores basic types like this...

    I think people think it's less useful to provide type def info for these built-in types...

    I'm happy to change the behavior, we can discuss this offline.

    Alan Donovan

    I think this is more of an existing behavior. Gopls ignores basic types like this...
    I think people think it's less useful to provide type def info for these built-in types...

    This is historically correct, but perhaps built-in types were rejected because TypeDefinition could (until now) report only a single type, so ignoring built-in types helped us locate the one type of interest. But if we can now report on all the named types in (say) the result tuple of a function call, then I see no reason not to treat them all consistently. We should of course check the ergonomics in VS Code (and I can check in Emacs+eglot) before committing.

    Hongxiang Jiang

    SG. I will add a TODO here in case I forgot about this. I'm happy to have another patch later to make the behavior consistent between all these types.


    Comment added in `gopls/internal/golang/type_definition.go`

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alan Donovan
    • Madeline Kalil
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: tools
    Gerrit-Branch: master
    Gerrit-Change-Id: Id5076268fb0458720693a30868e44e2cf0952395
    Gerrit-Change-Number: 728880
    Gerrit-PatchSet: 3
    Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
    Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
    Gerrit-Attention: Madeline Kalil <mka...@google.com>
    Gerrit-Attention: Alan Donovan <adon...@google.com>
    Gerrit-Comment-Date: Mon, 15 Dec 2025 03:34:48 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Madeline Kalil <mka...@google.com>
    Comment-In-Reply-To: Hongxiang Jiang <hxj...@golang.org>
    Comment-In-Reply-To: Alan Donovan <adon...@google.com>
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Madeline Kalil (Gerrit)

    unread,
    Dec 15, 2025, 11:02:55 AM (yesterday) Dec 15
    to Hongxiang Jiang, goph...@pubsubhelper.golang.org, Go LUCI, Alan Donovan, golang-co...@googlegroups.com
    Attention needed from Alan Donovan and Hongxiang Jiang

    Madeline Kalil added 1 comment

    File gopls/internal/test/marker/testdata/typedef/typedef.txt
    Line 49, Patchset 1:func F5() (Struct, int, bool, error) { return Struct{}, 0, false, nil }
    Madeline Kalil . resolved

    General question: why can you jump to definition on basic types like int, bool, but can't do a type def query on these? Shouldn't they jump to the same place, in the same way that type def and normal def on "error" jump to the same place?

    Hongxiang Jiang

    I think this is more of an existing behavior. Gopls ignores basic types like this...

    I think people think it's less useful to provide type def info for these built-in types...

    I'm happy to change the behavior, we can discuss this offline.

    Alan Donovan

    I think this is more of an existing behavior. Gopls ignores basic types like this...
    I think people think it's less useful to provide type def info for these built-in types...

    This is historically correct, but perhaps built-in types were rejected because TypeDefinition could (until now) report only a single type, so ignoring built-in types helped us locate the one type of interest. But if we can now report on all the named types in (say) the result tuple of a function call, then I see no reason not to treat them all consistently. We should of course check the ergonomics in VS Code (and I can check in Emacs+eglot) before committing.

    Hongxiang Jiang

    SG. I will add a TODO here in case I forgot about this. I'm happy to have another patch later to make the behavior consistent between all these types.


    Comment added in `gopls/internal/golang/type_definition.go`

    Madeline Kalil

    I have a CL that I need to rebase on top of your work and finish that will fix this in gopls: https://go-review.git.corp.google.com/c/tools/+/729740

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alan Donovan
    • Hongxiang Jiang
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: tools
      Gerrit-Branch: master
      Gerrit-Change-Id: Id5076268fb0458720693a30868e44e2cf0952395
      Gerrit-Change-Number: 728880
      Gerrit-PatchSet: 3
      Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
      Gerrit-Reviewer: Alan Donovan <adon...@google.com>
      Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
      Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
      Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
      Gerrit-Attention: Alan Donovan <adon...@google.com>
      Gerrit-Comment-Date: Mon, 15 Dec 2025 16:02:10 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Hongxiang Jiang (Gerrit)

      unread,
      Dec 15, 2025, 8:47:13 PM (18 hours ago) Dec 15
      to goph...@pubsubhelper.golang.org, Go LUCI, Madeline Kalil, Alan Donovan, golang-co...@googlegroups.com
      Attention needed from Alan Donovan and Madeline Kalil

      Hongxiang Jiang added 1 comment

      File gopls/internal/test/marker/testdata/typedef/typedef.txt
      Line 49, Patchset 1:func F5() (Struct, int, bool, error) { return Struct{}, 0, false, nil }
      Madeline Kalil . resolved

      General question: why can you jump to definition on basic types like int, bool, but can't do a type def query on these? Shouldn't they jump to the same place, in the same way that type def and normal def on "error" jump to the same place?

      Hongxiang Jiang

      I think this is more of an existing behavior. Gopls ignores basic types like this...

      I think people think it's less useful to provide type def info for these built-in types...

      I'm happy to change the behavior, we can discuss this offline.

      Alan Donovan

      I think this is more of an existing behavior. Gopls ignores basic types like this...
      I think people think it's less useful to provide type def info for these built-in types...

      This is historically correct, but perhaps built-in types were rejected because TypeDefinition could (until now) report only a single type, so ignoring built-in types helped us locate the one type of interest. But if we can now report on all the named types in (say) the result tuple of a function call, then I see no reason not to treat them all consistently. We should of course check the ergonomics in VS Code (and I can check in Emacs+eglot) before committing.

      Hongxiang Jiang

      SG. I will add a TODO here in case I forgot about this. I'm happy to have another patch later to make the behavior consistent between all these types.


      Comment added in `gopls/internal/golang/type_definition.go`

      Madeline Kalil

      I have a CL that I need to rebase on top of your work and finish that will fix this in gopls: https://go-review.git.corp.google.com/c/tools/+/729740

      Hongxiang Jiang

      Feel free to review this change and the previous change so we can merge the CLs.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Alan Donovan
      • Madeline Kalil
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: tools
      Gerrit-Branch: master
      Gerrit-Change-Id: Id5076268fb0458720693a30868e44e2cf0952395
      Gerrit-Change-Number: 728880
      Gerrit-PatchSet: 3
      Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
      Gerrit-Reviewer: Alan Donovan <adon...@google.com>
      Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
      Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
      Gerrit-Attention: Madeline Kalil <mka...@google.com>
      Gerrit-Attention: Alan Donovan <adon...@google.com>
      Gerrit-Comment-Date: Tue, 16 Dec 2025 01:47:06 +0000
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Madeline Kalil (Gerrit)

      unread,
      10:51 AM (4 hours ago) 10:51 AM
      to Hongxiang Jiang, goph...@pubsubhelper.golang.org, Go LUCI, Alan Donovan, golang-co...@googlegroups.com
      Attention needed from Alan Donovan and Hongxiang Jiang

      Madeline Kalil voted Code-Review+2

      Code-Review+2
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Alan Donovan
      • Hongxiang Jiang
      Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: tools
      Gerrit-Branch: master
      Gerrit-Change-Id: Id5076268fb0458720693a30868e44e2cf0952395
      Gerrit-Change-Number: 728880
      Gerrit-PatchSet: 3
      Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
      Gerrit-Reviewer: Alan Donovan <adon...@google.com>
      Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
      Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
      Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
      Gerrit-Attention: Alan Donovan <adon...@google.com>
      Gerrit-Comment-Date: Tue, 16 Dec 2025 15:51:31 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Hongxiang Jiang (Gerrit)

      unread,
      2:18 PM (18 minutes ago) 2:18 PM
      to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Madeline Kalil, Go LUCI, Alan Donovan, golang-co...@googlegroups.com

      Hongxiang Jiang submitted the change

      Change information

      Commit message:
      gopls/internal/test/marker: add optional error to typedef marker

      The typedef marker now accept optional input parameter error to
      verify if the typedef returns an expected error from gopls.

      Also migrate regression test for golang/go#60544 from integration
      to marker test.

      For golang/go#76723
      Change-Id: Id5076268fb0458720693a30868e44e2cf0952395
      Reviewed-by: Madeline Kalil <mka...@google.com>
      Files:
      • M gopls/internal/golang/type_definition.go
      • M gopls/internal/test/integration/misc/definition_test.go
      • M gopls/internal/test/marker/doc.go
      • M gopls/internal/test/marker/marker_test.go
      • A gopls/internal/test/marker/testdata/typedef/issue60544.txt
      • M gopls/internal/test/marker/testdata/typedef/typedef.txt
        Change size: M
        Delta: 6 files changed, 50 insertions(+), 46 deletions(-)
        Branch: refs/heads/master
        Submit Requirements:
        • requirement satisfiedCode-Review: +2 by Madeline Kalil
        • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
        Open in Gerrit
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: merged
        Gerrit-Project: tools
        Gerrit-Branch: master
        Gerrit-Change-Id: Id5076268fb0458720693a30868e44e2cf0952395
        Gerrit-Change-Number: 728880
        Gerrit-PatchSet: 4
        open
        diffy
        satisfied_requirement
        Reply all
        Reply to author
        Forward
        0 new messages