1
0
mirror of https://github.com/golang/go synced 2024-09-29 16:34:31 -06:00
go/misc/cgo/errors
Robert Griesemer 2a5cf48f91 cmd/compile: print columns (not just lines) in error messages
Compiler errors now show the exact line and line byte offset (sometimes
called "column") of where an error occured. For `go tool compile x.go`:

	package p
	const c int = false
	//line foo.go:123
	type t intg

reports

	x.go:2:7: cannot convert false to type int
	foo.go:123[x.go:4:8]: undefined: intg

(Some errors use the "wrong" position for the error message; arguably
the byte offset for the first error should be 15, the position of 'false',
rathen than 7, the position of 'c'. But that is an indepedent issue.)

The byte offset (column) values are measured in bytes; they start at 1,
matching the convention used by editors and IDEs.

Positions modified by //line directives show the line offset only for the
actual source location (in square brackets), not for the "virtual" file and
line number because that code is likely generated and the //line directive
only provides line information.

Because the new format might break existing tools or scripts, printing
of line offsets can be disabled with the new compiler flag -C. We plan
to remove this flag eventually.

Fixes #10324.

Change-Id: I493f5ee6e78457cf7b00025aba6b6e28e50bb740
Reviewed-on: https://go-review.googlesource.com/37970
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-09 23:29:49 +00:00
..
err1.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
err2.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
err3.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
issue7757.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
issue8442.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
issue11097a.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
issue11097b.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
issue13129.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
issue13423.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
issue13635.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
issue13830.go cmd/cgo: use function arg type for _cgoCheckPointerN function 2016-06-09 16:02:03 +00:00
issue14669.go cmd/cgo: remove -O options when generating compiler errors 2016-05-27 01:40:30 +00:00
issue16116.go cmd/cgo: error, not panic, if not enough arguments to function 2016-06-21 04:32:04 +00:00
issue16591.go cmd/cgo: always use a function literal for pointer checking 2016-10-19 21:20:50 +00:00
malloc.go misc/cgo/errors: fix malloc test for dragonfly 2016-10-25 20:11:50 +00:00
ptr.go cmd/cgo: run cgo pointer checks for pointer to union 2016-11-15 17:10:52 +00:00
test.bash cmd/compile: print columns (not just lines) in error messages 2017-03-09 23:29:49 +00:00