Skip to content
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, types2: panic in eager error reporting for interface types #48234

Closed
findleyr opened this issue Sep 8, 2021 · 3 comments
Closed

go/types, types2: panic in eager error reporting for interface types #48234

findleyr opened this issue Sep 8, 2021 · 3 comments
Assignees
Milestone

Comments

@findleyr
Copy link
Contributor

@findleyr findleyr commented Sep 8, 2021

Type checking the following code panics at tip in go/types:

package p                                                                                                                                                                                                            
                                                                                                                                                                                                                     
var _ int = interface{m();m()}(nil)

Stack snippet:

panic: 198: duplicate method m [recovered]                                                                                                                                                                           
        panic: 198: duplicate method m [recovered]                                                        
        panic: 198: duplicate method m                                                                                                                                                                               
                                                     
goroutine 7 [running]:                                                                                    
testing.tRunner.func1.2({0x643160, 0xc00012c7e0})                                                                                                                                                                    
        /home/rfindley/src/go/src/testing/testing.go:1209 +0x24e                                                                                                                                                     
testing.tRunner.func1()                              
        /home/rfindley/src/go/src/testing/testing.go:1212 +0x225                                                                                                                                                     
panic({0x643160, 0xc00012c7e0})                                                                           
        /home/rfindley/src/go/src/runtime/panic.go:814 +0x207                                                                                                                                                        
go/types.(*Checker).handleBailout(0xc000140780, 0xc0000c5b58)                                                                                                                                                        
        /home/rfindley/src/go/src/go/types/check.go:244 +0x8b                                                                                                                                                        
panic({0x643160, 0xc00012c7e0})                                                                           
        /home/rfindley/src/go/src/runtime/panic.go:814 +0x207                                                                                                                                                        
go/types.computeInterfaceTypeSet.func2(0xc6, 0xc00014e0f0, 0x1)                                                                                                                                                      
        /home/rfindley/src/go/src/go/types/typeset.go:224 +0x565                                                                                                                                                     
go/types.computeInterfaceTypeSet(0x0, 0x6ea580, 0xc00010bf90)                                                                                                                                                        
        /home/rfindley/src/go/src/go/types/typeset.go:251 +0x208                                                                                                                                                     
go/types.(*Interface).typeSet(...)                                                                        
        /home/rfindley/src/go/src/go/types/interface.go:27                                                                                                                                                           
go/types.(*Interface).IsConstraint(0x6ea580)                                                              
        /home/rfindley/src/go/src/go/types/interface.go:107 +0x25                                                                                                                                                    
go/types.(*Checker).callExpr(0xc000140780, 0xc000029fc0, 0xc000029ec0)                                                                                                                                               
        /home/rfindley/src/go/src/go/types/call.go:121 +0x492                                                                                                                                                        
go/types.(*Checker).exprInternal(0xc000140780, 0xc000029fc0, {0x6eabc8, 0xc000029ec0}, {0x0, 0x0})                                                                                                                   
        /home/rfindley/src/go/src/go/types/expr.go:1436 +0x945                                                                                                                                                       
go/types.(*Checker).rawExpr(0x8583c0, 0xc000029fc0, {0x6eabc8, 0xc000029ec0}, {0x0, 0x0}, 0x0)                                                                                                                       
        /home/rfindley/src/go/src/go/types/expr.go:1075 +0x45                                                                                                                                                        
go/types.(*Checker).expr(0xc000140780, 0x6eaec8, {0x6eabc8, 0xc000029ec0})                                                                                                                                           
        /home/rfindley/src/go/src/go/types/expr.go:1559 +0x35                                                                                                                                                        
go/types.(*Checker).varDecl(0x64c9e0, 0xc00010bf40, {0xc00000e4b8, 0x20, 0x1}, {0x6eaec8, 0xc00013e180}, {0x6eabc8, 0xc000029ec0})
        /home/rfindley/src/go/src/go/types/decl.go:537 +0x176                                                                                                                                                        
go/types.(*Checker).objDecl(0xc000140780, {0x6f4958, 0xc00010bf40}, 0x589780)                                                                                                                                        
        /home/rfindley/src/go/src/go/types/decl.go:193 +0x665

On the dev.typeparams branch, we'd whittled down the need for explicit interface completion, but missed this type of eager error reporting (the error is encountered when checking assignability of the interface type, before all objects are resolved and interface type sets computed normally).

CC @griesemer

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 8, 2021

Change https://golang.org/cl/348371 mentions this issue: go/types: temporarily pin the Checker to InterfaceType during checking

Loading

@gopherbot gopherbot closed this in c8d4fe2 Sep 8, 2021
@findleyr
Copy link
Contributor Author

@findleyr findleyr commented Sep 8, 2021

Err, reopening to track the change in types2.

Loading

@findleyr findleyr reopened this Sep 8, 2021
@findleyr
Copy link
Contributor Author

@findleyr findleyr commented Sep 9, 2021

Ported to types2 in https://golang.org/cl/348575

Loading

@findleyr findleyr closed this Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants