• Robert Griesemer's avatar
    cmd/compile: print columns (not just lines) in error messages · 2a5cf48f
    Robert Griesemer authored
    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/37970Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
    2a5cf48f
Name
Last commit
Last update
..
errors Loading commit data...
fortran Loading commit data...
gmp Loading commit data...
life Loading commit data...
nocgo Loading commit data...
stdio Loading commit data...
test Loading commit data...
testasan Loading commit data...
testcarchive Loading commit data...
testcshared Loading commit data...
testgodefs Loading commit data...
testplugin Loading commit data...
testsanitizers Loading commit data...
testshared Loading commit data...
testsigfwd Loading commit data...
testso Loading commit data...
testsovar Loading commit data...
testtls Loading commit data...