]> Cypherpunks repositories - gostls13.git/commit
go/token: correct out-of-bounds token offsets and positions
authorRobert Griesemer <gri@golang.org>
Wed, 31 Jan 2024 01:16:12 +0000 (17:16 -0800)
committerGopher Robot <gobot@golang.org>
Wed, 31 Jan 2024 20:26:14 +0000 (20:26 +0000)
commita5fb65601e7e51f702fc1b3ea9e956f217449b55
tree4cb4859618c8254b06056fe266e4b46d6da11f43
parent79738217d53f6b2d06d47a2233e51cc859d69e8d
go/token: correct out-of-bounds token offsets and positions

Per the discussion on the issue, make methods that depend on
incoming offsets or positions tolerant in the presence of
out-of-bounds values by adjusting the values as needed.

Add an internal flag debug that can be set to enable the old
(not fault-tolerant) behavior.

Fixes #57490.

Change-Id: I8a7d422b9fd1d6f0980fd4e64da2f0489056d71e
Reviewed-on: https://go-review.googlesource.com/c/go/+/559436
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
src/go/parser/parser_test.go
src/go/token/position.go
src/go/token/position_test.go