-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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: Support 1.23 (Transparent aliases) #17358
Conversation
I think you will have a problem with the multiple fields (objects, in CodeQL Entity) representing the same struct-type's field. For example, if we have struct { x int }
type IntAlias = int
struct { x IntAlias } Then we will call Potential difference between the two approaches here: because you're conflating the two struct types in |
7fca405
to
5fd2e87
Compare
Confirmed the above is not in fact a problem: because more than one type maps onto the same TRAP label (e.g. |
168afee
to
034c823
Compare
034c823
to
f06fa18
Compare
// Determines whether the given type is an alias. | ||
func isAlias(tp types.Type) bool { | ||
_, ok := tp.(*types.Alias) | ||
return ok | ||
} | ||
|
||
// If the given type is a type alias, this function resolves it to its underlying type. | ||
func resolveTypeAlias(tp types.Type) types.Type { | ||
if isAlias(tp) { | ||
return types.Unalias(tp) // tp.Underlying() | ||
} | ||
return tp | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is all redundant and we can just use types.Unalias. But this can be done in a follow-up PR.
// Determines whether the given type is an alias. | |
func isAlias(tp types.Type) bool { | |
_, ok := tp.(*types.Alias) | |
return ok | |
} | |
// If the given type is a type alias, this function resolves it to its underlying type. | |
func resolveTypeAlias(tp types.Type) types.Type { | |
if isAlias(tp) { | |
return types.Unalias(tp) // tp.Underlying() | |
} | |
return tp | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well spotted. Yes, none of this is necessary anymore with the current version of this PR since Unalias
implements the same logic. Agree that we can remove it later since it doesn't impact the behaviour.
Now that 1.23.1 has been released, fixing a crash bug which was affecting us, shall we update to that? |
5ec862d
to
772bc9b
Compare
The CI failure for "Go Resolve Build Environment Tests" is expected until the corresponding, internal PR has been merged. QA experiment results look good. Merging now. |
This PR is an alternative to the line of work in #17058 which tries to keep the changes required to tolerate Go 1.23 more minimal. The main difference is that in #17058 we explicitly extract
Alias
types, store them in the database, and then consequently have to deal with type equality issues that arise from this. In contrast, we do not explicitly extract theAlias
types in this PR and instead just use the Go compiler to resolve them to their underlying types directly. This has the benefit that much fewer changes are needed to tolerate Go 1.23 extraction and that the behaviour is the same as before Go 1.23. The downside is that no information about aliases is available to query writers.