scanner: Update prevPos even when returning utf8.RuneError.
The calling code will still call unread(), causing panics. This fixes the TestScanHeredocRegexpCompile() unit test.
This commit is contained in:
parent
73fde59edb
commit
fdaaf22252
@ -74,14 +74,6 @@ func (s *Scanner) next() rune {
|
||||
return eof
|
||||
}
|
||||
|
||||
if ch == utf8.RuneError && size == 1 {
|
||||
s.srcPos.Column++
|
||||
s.srcPos.Offset += size
|
||||
s.lastCharLen = size
|
||||
s.err("illegal UTF-8 encoding")
|
||||
return ch
|
||||
}
|
||||
|
||||
// remember last position
|
||||
s.prevPos = s.srcPos
|
||||
|
||||
@ -89,6 +81,11 @@ func (s *Scanner) next() rune {
|
||||
s.lastCharLen = size
|
||||
s.srcPos.Offset += size
|
||||
|
||||
if ch == utf8.RuneError && size == 1 {
|
||||
s.err("illegal UTF-8 encoding")
|
||||
return ch
|
||||
}
|
||||
|
||||
if ch == '\n' {
|
||||
s.srcPos.Line++
|
||||
s.lastLineLen = s.srcPos.Column
|
||||
|
Loading…
Reference in New Issue
Block a user