-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go/types: initialization cycle errors are non-deterministic #71254
Comments
We may not have written it down (and perhaps we should) but, I think all the go/types maintainers agree that it should be deterministic, even if it requires extra logic and computation to (e.g.) iterate over graphs in a particular order. This property is invaluable for debugging and well worth the effort. |
Related Issues
Related Code Changes (Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
I would go so far as to consider this a bug: type checking should be entirely deterministic. |
// findPath returns the (reversed) list of objects []Object{to, ... from}
// such that there is a path of object dependencies from 'from' to 'to'.
// If there is no such path, the result is nil.
func findPath(objMap map[Object]*declInfo, from, to Object, seen map[Object]bool) []Object {
if seen[from] {
return nil
}
seen[from] = true
for d := range objMap[from].deps {
if d == to {
return []Object{d}
}
if P := findPath(objMap, d, to, seen); P != nil {
return append(P, d)
}
}
return nil
} The problem is that the |
@wingrez Feel free to submit a CL for review; I expect this to be a very simple change. Thanks. |
Change https://go.dev/cl/642396 mentions this issue: |
Type-checking such code:
leads to non-deterministic errors, either:
or
or
It would be nice if
go/types
always returned the same error for the same input. I am not sure whether this is something thatgo/types
should guarantee, feel free to close this issue, if that is fine.CC @adonovan @griesemer
The text was updated successfully, but these errors were encountered: