diff options
author | Robert Griesemer <gri@golang.org> | 2017-03-09 13:38:10 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2017-03-09 23:28:48 +0000 |
commit | 1f9f0ea32b2dcee027b107f2c3d0bc723274a810 (patch) | |
tree | 1c3d499526e0ab668b714ebc2cb0ac1ed76fb7dc /src/cmd/compile/internal/syntax/nodes_test.go | |
parent | bfc164c64d33edfaf774b5c29b9bf5648a6447fb (diff) | |
download | go-1f9f0ea32b2dcee027b107f2c3d0bc723274a810.tar.gz go-1f9f0ea32b2dcee027b107f2c3d0bc723274a810.zip |
cmd/compile/internal/syntax: start line offset (column) numbers at 1
We could leave it alone and fix line offset (column) numbers when
reporting errors, but that is likely to cause confusion (internal
numbers don't match reported numbers). Instead, switch to default
numbering starting at 1.
For package syntax-internal use only, introduced constants defining
the line and column bases, and use them throughout the code and its
tests. It is possible to change these constants and package syntax
will continue to work. But changing them is going to break any client
that makes explicit assumptions about line and column numbers (which
is "all of them").
Change-Id: Ia3d136a8ec8d9372ed9c05ca47d3dff222cf030e
Reviewed-on: https://go-review.googlesource.com/37996
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/nodes_test.go')
-rw-r--r-- | src/cmd/compile/internal/syntax/nodes_test.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/syntax/nodes_test.go b/src/cmd/compile/internal/syntax/nodes_test.go index 6b4119c70b..47283bc4d2 100644 --- a/src/cmd/compile/internal/syntax/nodes_test.go +++ b/src/cmd/compile/internal/syntax/nodes_test.go @@ -297,8 +297,8 @@ func testPos(t *testing.T, list []test, prefix, suffix string, extract func(*Fil } // verify node position with expected position as indicated by @ - if col := int(node.Pos().Col()); col != index { - t.Errorf("pos error: %s: col = %d, want %d", src, col, index) + if col := int(node.Pos().Col()); col != index+colbase { + t.Errorf("pos error: %s: col = %d, want %d", src, col, index+colbase) continue } } |