-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
sizegen: do not ignore type aliases #17556
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,6 +163,8 @@ func (sizegen *sizegen) generateTyp(tt types.Type) { | |
sizegen.generateKnownType(tt) | ||
case *types.Alias: | ||
sizegen.generateTyp(types.Unalias(tt)) | ||
default: | ||
panic(fmt.Sprintf("unhandled type: %v (%T)", tt, tt)) | ||
} | ||
} | ||
|
||
|
@@ -490,9 +492,11 @@ func (sizegen *sizegen) sizeStmtForType(fieldName *jen.Statement, field types.Ty | |
// assume that function pointers do not allocate (although they might, if they're closures) | ||
return nil, 0 | ||
|
||
case *types.Alias: | ||
return sizegen.sizeStmtForType(fieldName, types.Unalias(node), alloc) | ||
|
||
default: | ||
log.Printf("unhandled type: %T", node) | ||
return nil, 0 | ||
panic(fmt.Sprintf("unhandled type: %v (%T)", node, node)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not just print a warning here, but actively panic. This is so that if we have other new types in the future, we don't ignore this again but actively investigate. |
||
} | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
We now make sure we panic here on unexpected values as well.