-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/analysisinternal: avoid sub-token spans in TypeErrorEndPos
Avoid assigning end positions to type errors that are within the current token (such as could happen in an import path). To test this, introduce our first named argument in the marker tests: 'exact' for the @diag marker. Also, attempt to document the heuristic of TypeErrorEndPos. Fixes golang/go#69505 Change-Id: If3cf82f241dd354d834a7dcbf24b7b3c59246911 Reviewed-on: https://go-review.googlesource.com/c/tools/+/625916 Auto-Submit: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
- Loading branch information
Showing
4 changed files
with
114 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
gopls/internal/test/marker/testdata/diagnostics/issue69505.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
This test checks that diagnostics ranges computed with the TypeErrorEndPos | ||
heuristic span at least a full token. | ||
|
||
-- go.mod -- | ||
module example.com | ||
|
||
go 1.21 | ||
|
||
-- main.go -- | ||
package main | ||
|
||
import "example.com/foo-bar" //@ diag(re`"[^"]*"`, re`not used`, exact=true) | ||
|
||
func f(int) {} | ||
|
||
func main() { | ||
var x int | ||
_ = x + 1.e+0i //@ diag("1.e+0i", re`truncated`, exact=true) | ||
} | ||
|
||
-- foo-bar/baz.go -- | ||
package foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters