Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: bad line number in error message calling variadic function #23660

Open
josharian opened this issue Feb 2, 2018 · 3 comments
Open
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@josharian
Copy link
Contributor

Compile:

package p

import git "gopkg.in/libgit2/git2go.v26"

func f(r *git.Repository, x int) {
	r.CreateCommit(
		"",
		nil,
		nil,
		"",
		nil,
		x,
	)
}

Result:

$ go build x.go
# command-line-arguments
./x.go:10:3: cannot use x (type int) as type *git.Commit in argument to r.CreateCommit

The correct line number is 12, not 10. Line 10 is the second "" line.

Reproduces with (at a minimum): 1.7, 1.8, 1.9, and 1.10rc1.

@mdempsky @griesemer

@josharian josharian added the NeedsFix The path to resolution is known, but the work has not been done. label Feb 2, 2018
@josharian josharian added this to the Go1.11 milestone Feb 2, 2018
@ianlancetaylor ianlancetaylor modified the milestones: Go1.11, Go1.12 Jun 30, 2018
@odeke-em
Copy link
Member

Thank you for reporting this bug @josharian!

So interestingly this bug only triggers if the mismatched element is an argument.

For example at https://play.golang.org/p/IeO4Zyw_8xq or inlined below for brevity

package main

type Repository int
type Signature int
type Oid int
type Tree int
type Commit int

func CreateCommit(
	refname string, author, committer *Signature,
	message string, tree *Tree, parents ...*Commit) (*Oid, error) {
	return nil, nil
}

func f1(x int) {
	CreateCommit(
		"",
		nil,
		nil,
		"",
		nil,
		x,
	)
}

func f2() {
	CreateCommit(
		"",
		nil,
		nil,
		"",
		nil,
		4,
	)
}

func main() {}

Gives
screen shot 2018-10-18 at 2 45 46 am

Notice that for the second function f2, the position is properly printed, while for f1 it matches your report?

Hopefully this will help with an easier prognosis and bug fix.

@gopherbot
Copy link

Change https://golang.org/cl/147379 mentions this issue: cmd/compile: Store original positions for Nodes elements

@griesemer
Copy link
Contributor

Too late for 1.12.

@griesemer griesemer modified the milestones: Go1.12, Go1.13 Nov 28, 2018
@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
Status: Triage Backlog
Development

No branches or pull requests

8 participants