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
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@findleyr
Copy link
Contributor

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

@findleyr findleyr added NeedsFix The path to resolution is known, but the work has not been done. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 8, 2021
@findleyr findleyr added this to the Go1.18 milestone Sep 8, 2021
@gopherbot gopherbot removed the NeedsFix The path to resolution is known, but the work has not been done. label Sep 8, 2021
@gopherbot
Copy link
Contributor

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

@findleyr
Copy link
Contributor Author

findleyr commented Sep 8, 2021

Err, reopening to track the change in types2.

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

findleyr commented Sep 9, 2021

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

@findleyr findleyr closed this as completed Sep 9, 2021
@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants