-
Notifications
You must be signed in to change notification settings - Fork 918
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
compiler crash on interface assert #3788
Comments
The out of range panic is because
here is some info from debugging this:
|
/cc @aykevl |
@dgryski @aykevl I did some more investigation on this issue. It appears that the issue is caused by the type not having a method set.
The panicking operation is
I think the fix is to check if the type has a method set before trying to get the pointer to the method set that doesn't exist, but I don't know how to do this. How can I check for a valid method set in this code? I noticed that methods is an empty string after calling getMethodsString here:
|
…rg#3788) This commit refines the logic of type assertion for handling interfaces. Previously, the logic only checked if the asserted type was an interface, leading to a compiler panic when the interface did not have any methods. The updated logic correctly handles type assertion by checking if the asserted interface type has methods. Moreover, if the type only implements the empty interface (i.e., has no methods), it is now correctly converted into a runtime type assert call.
hit this issue as well. |
Completed with |
Hi @deadprogram! I think it actually wasn't fixed as the original bug is still there in version 0.31.0. Given a file containing: // main.go
package main
func init() {
_ = any(0).(interface{ x() }) // this crashes the compiler
}
func main() {} Running you get:
Right now, only the case of: _ = any(0).(any) // this crashes the compiler got fixed. Can we reopen this issue? Last, I opened some time ago a fix to this issue. Could you take a look? |
I originally noticed this issue while investigating another issue: #3771 (comment)
this is a small reproducer:
The text was updated successfully, but these errors were encountered: