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

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

josharian opened this issue Feb 2, 2018 · 3 comments
Assignees
Labels
Milestone

Comments

@josharian
Copy link
Contributor

@josharian josharian commented Feb 2, 2018

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 this to the Go1.11 milestone Feb 2, 2018
@ianlancetaylor ianlancetaylor removed this from the Go1.11 milestone Jun 30, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.12 milestone Jun 30, 2018
@odeke-em
Copy link
Member

@odeke-em odeke-em commented Oct 18, 2018

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.

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Nov 5, 2018

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

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Nov 28, 2018

Too late for 1.12.

Loading

@griesemer griesemer removed this from the Go1.12 milestone Nov 28, 2018
@griesemer griesemer added this to the Go1.13 milestone Nov 28, 2018
@andybons andybons removed this from the Go1.13 milestone Jul 8, 2019
@andybons andybons added this to the Go1.14 milestone Jul 8, 2019
@rsc rsc removed this from the Go1.14 milestone Oct 9, 2019
@rsc rsc added this to the Backlog milestone Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants