go/types2, types2: version check (Checker.allowVersion) ignores module version if position information is missing #66274
Labels
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
The code in
Checker.allowVersion
:returns true if
pos
is not known:fileVersions
won't be set and thus is not valid, resulting in atrue
return value.This leads to correct behavior if a position is missing because it belongs to an imported object/type: in those cases we don't need to do a version check (== any version is allowed). But it may hide problems due to incorrectly missing position information.
Instead, the code should resort to the module version if no position is provided, and code that is version checking should not do the version checks if the checks are not needed in the first place (for imported types/objects).
This code exists also in 1.22 and it hides issue #66064 (in 1.22) because the missing position information effectively leads to an absent version check (which is what we want).
A more robust approach is to explicitly disable the version check if none is needed, and assert that in all other cases we have a valid position.
cc: @findleyr for visibilty
The text was updated successfully, but these errors were encountered: