-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d790d1f
Go: Use 1.23 in build process
mbg ca796b0
Go: Use 1.23 in tests
mbg 4dead2b
Go: Use 1.23 for extractor
mbg c8e7324
Go: Update frontend error messages for Go 1.23
mbg c5b8163
Go: Handle `Alias` types by extracting the underlying types
mbg 97c3efc
Go: Factor out `isAlias` function
mbg 1a9608a
Go: Don't extract objects for type aliases
mbg 8380d71
Go: Add test for `AliasType` extraction
mbg 195f372
Go: Accept new test results
mbg 6ef5063
Go: Format `Aliases.ql`
mbg 9aeaae6
Go: Bump `maxGoVersion` to `1.23`
mbg 772bc9b
Go: Bump everything to 1.23.1
mbg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
2 changes: 1 addition & 1 deletion
2
go/ql/test/extractor-tests/diagnostics/CONSISTENCY/UnexpectedFrontendErrors.expected
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
2 changes: 1 addition & 1 deletion
2
go/ql/test/library-tests/semmle/go/Files/CONSISTENCY/UnexpectedFrontendErrors.expected
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
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,20 @@ | ||
entities | ||
| aliases.go | aliases.go:3:6:3:13 | aliasesX | 1 | file://:0:0:0:0 | int | | ||
| aliases.go | aliases.go:4:6:4:13 | aliasesY | 1 | file://:0:0:0:0 | int | | ||
| aliases.go | aliases.go:6:6:6:14 | aliasesS1 | 1 | file://:0:0:0:0 | struct type | | ||
| aliases.go | aliases.go:6:26:6:26 | x | 3 | file://:0:0:0:0 | int | | ||
| aliases.go | aliases.go:8:6:8:14 | aliasesS2 | 1 | file://:0:0:0:0 | struct type | | ||
| aliases.go | aliases.go:8:26:8:26 | x | 3 | file://:0:0:0:0 | int | | ||
| aliases.go | aliases.go:10:6:10:6 | F | 1 | file://:0:0:0:0 | signature type | | ||
| aliases.go | aliases.go:10:8:10:11 | Afs1 | 1 | file://:0:0:0:0 | struct type | | ||
| aliases.go | aliases.go:14:6:14:6 | G | 1 | file://:0:0:0:0 | signature type | | ||
| aliases.go | aliases.go:14:8:14:11 | Afs2 | 1 | file://:0:0:0:0 | struct type | | ||
| aliases.go | aliases.go:19:6:19:7 | S3 | 1 | aliases.go:19:6:19:7 | S3 | | ||
| aliases.go | aliases.go:19:17:19:17 | x | 3 | file://:0:0:0:0 | int | | ||
| aliases.go | aliases.go:22:6:22:6 | T | 1 | aliases.go:19:6:19:7 | S3 | | ||
| aliases.go | aliases.go:25:6:25:6 | H | 1 | file://:0:0:0:0 | signature type | | ||
| aliases.go | aliases.go:25:8:25:11 | Afs3 | 1 | aliases.go:19:6:19:7 | S3 | | ||
#select | ||
| F | func(struct { x int }) int | | ||
| G | func(struct { x int }) int | | ||
| H | func(S3) int | |
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,21 @@ | ||
import go | ||
|
||
int countDecls(Entity e) { result = count(Ident decl | decl = e.getDeclaration()) } | ||
|
||
query predicate entities(string fp, Entity e, int c, Type ty) { | ||
c = countDecls(e) and | ||
ty = e.getType() and | ||
exists(DbLocation loc | | ||
loc = e.getDeclaration().getLocation() and | ||
fp = loc.getFile().getBaseName() and | ||
fp = "aliases.go" | ||
) | ||
} | ||
|
||
from string fp, FuncDecl decl, SignatureType sig | ||
where | ||
decl.hasLocationInfo(fp, _, _, _, _) and | ||
decl.getName() = ["F", "G", "H"] and | ||
sig = decl.getType() and | ||
fp.matches("%aliases.go%") | ||
select decl.getName(), sig.pp() |
3 changes: 3 additions & 0 deletions
3
go/ql/test/library-tests/semmle/go/Types/Field_getPackage.expected
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
3 changes: 3 additions & 0 deletions
3
go/ql/test/library-tests/semmle/go/Types/Field_hasQualifiedName2.expected
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
3 changes: 3 additions & 0 deletions
3
go/ql/test/library-tests/semmle/go/Types/Field_hasQualifiedName3.expected
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
1 change: 1 addition & 0 deletions
1
go/ql/test/library-tests/semmle/go/Types/QualifiedNames.expected
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
3 changes: 3 additions & 0 deletions
3
go/ql/test/library-tests/semmle/go/Types/SignatureType_getNumParameter.expected
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
3 changes: 3 additions & 0 deletions
3
go/ql/test/library-tests/semmle/go/Types/SignatureType_getNumResult.expected
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
3 changes: 3 additions & 0 deletions
3
go/ql/test/library-tests/semmle/go/Types/StructFields.expected
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
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,27 @@ | ||
package main | ||
|
||
type aliasesX = int | ||
type aliasesY = int | ||
|
||
type aliasesS1 = struct{ x aliasesX } | ||
|
||
type aliasesS2 = struct{ x aliasesY } | ||
|
||
func F(Afs1 aliasesS1) int { | ||
return G(Afs1) + Afs1.x | ||
} | ||
|
||
func G(Afs2 aliasesS2) int { | ||
return Afs2.x | ||
} | ||
|
||
// This is a named type, not an alias | ||
type S3 struct{ x int } | ||
|
||
// This is a type alias | ||
type T = S3 | ||
|
||
// We expect `Afs3` to be of type `S3` here, not `struct{ x int }` | ||
func H(Afs3 T) int { | ||
return Afs3.x | ||
} |
2 changes: 1 addition & 1 deletion
2
go/ql/test/query-tests/Diagnostics/CONSISTENCY/UnexpectedFrontendErrors.expected
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
2 changes: 1 addition & 1 deletion
2
go/ql/test/query-tests/Summary/CONSISTENCY/UnexpectedFrontendErrors.expected
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.