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

Comments

Projects
None yet
6 participants
@josharian
Contributor

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 the NeedsFix 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

This comment has been minimized.

Member

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.

@gopherbot

This comment has been minimized.

gopherbot commented Nov 5, 2018

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

@griesemer

This comment has been minimized.

Contributor

griesemer commented Nov 28, 2018

Too late for 1.12.

@griesemer griesemer modified the milestones: Go1.12, Go1.13 Nov 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment