]> Cypherpunks repositories - gostls13.git/commit
go/scanner: the position of '\n's chars must be the last position of the current...
authorRobert Griesemer <gri@golang.org>
Fri, 26 Feb 2010 19:23:12 +0000 (11:23 -0800)
committerRobert Griesemer <gri@golang.org>
Fri, 26 Feb 2010 19:23:12 +0000 (11:23 -0800)
commit9520a68268e60f238d14a13d235c6296ab18369b
treee3e9bc9ce825231ba4ac808b247640f4d6fa866e
parent8c5404746ff2d14a1d3eacf78dfd25940411156e
go/scanner: the position of '\n's chars must be the last position of the current line

Background: This didn't matter until recently, because '\n' don't appear as token starts
in source code and thus the exact position was irrelevant (and set as was easiest in the
code). With auto semicolon insertion, a virtual semicolon may be inserted when a '\n' is
seen. The position of the semicolon is the position of the '\n'. Without this fix, these
semicolons appeared on the next line instead of the line where they were inserted.  This
affected the association of comments to declarations in the parser. As a result, some
lead comments where considered line comments, not collected in the ast, and not shown in
godoc pages. (This affected only godoc pages, not gofmt-formatted programs).

Fixes #592.

R=rsc
CC=golang-dev
https://golang.org/cl/224068
src/pkg/go/scanner/scanner.go
src/pkg/go/scanner/scanner_test.go