Skip to content

x/tools/gopls: completing argument to %p verb adds unwanted & for some types #65609

Closed
@dominikh

Description

@dominikh

gopls version

f4fa7a7

go env

-

What did you do?

Trigger completion at the end of

package pkg

import "fmt"

func foo() {
	var longword any
	fmt.Printf("%p", lon

What did you see happen?

The line completes to

fmt.Printf("%p", &longword

What did you expect to see?

fmt.Printf("%p", longword

The variable has an interface type. I intended to print the pointer stored in the interface value, not the address of the local variable.

The same happens with maps, channels, unsafe.Pointer, and functions, all of which are accepted by %p. It does not happen with true pointers, or slices.

Editor and settings

No response

Logs

No response

Metadata

Metadata

Labels

ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.help wanted

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions