@@ -1823,6 +1823,12 @@ func typeErrorsToDiagnostics(pkg *syntaxPackage, errs []types.Error, linkTarget
1823
1823
// report.
1824
1824
continue
1825
1825
}
1826
+
1827
+ // Invariant: both start and end are IsValid.
1828
+ if ! end .IsValid () {
1829
+ panic ("end is invalid" )
1830
+ }
1831
+
1826
1832
posn := safetoken .StartPosition (e .Fset , start )
1827
1833
if ! posn .IsValid () {
1828
1834
// All valid positions produced by the type checker should described by
@@ -1848,10 +1854,34 @@ func typeErrorsToDiagnostics(pkg *syntaxPackage, errs []types.Error, linkTarget
1848
1854
}
1849
1855
continue
1850
1856
}
1851
- if ! end .IsValid () || end == start {
1857
+
1858
+ // debugging #65960
1859
+ //
1860
+ // At this point, we know 'start' IsValid, and
1861
+ // StartPosition(start) worked (with e.Fset).
1862
+ //
1863
+ // If the asserted condition is true, 'start'
1864
+ // is also in range for pgf.Tok, which means
1865
+ // the PosRange failure must be caused by 'end'.
1866
+ if pgf .Tok != e .Fset .File (start ) {
1867
+ bug .Reportf ("internal error: inconsistent token.Files for pos" )
1868
+ }
1869
+
1870
+ if end == start {
1852
1871
// Expand the end position to a more meaningful span.
1853
1872
end = analysisinternal .TypeErrorEndPos (e .Fset , pgf .Src , start )
1873
+
1874
+ // debugging #65960
1875
+ if _ , err := safetoken .Offset (pgf .Tok , end ); err != nil {
1876
+ bug .Reportf ("TypeErrorEndPos returned invalid end: %v" , err )
1877
+ }
1878
+ } else {
1879
+ // debugging #65960
1880
+ if _ , err := safetoken .Offset (pgf .Tok , end ); err != nil {
1881
+ bug .Reportf ("ReadGo116ErrorData returned invalid end: %v" , err )
1882
+ }
1854
1883
}
1884
+
1855
1885
rng , err := pgf .Mapper .PosRange (pgf .Tok , start , end )
1856
1886
if err != nil {
1857
1887
bug .Reportf ("internal error: could not compute pos to range for %v: %v" , e , err )
0 commit comments