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/parser: panic due to duplicate resolution of sliced operand #44504

Closed
findleyr opened this issue Feb 22, 2021 · 1 comment
Closed

go/parser: panic due to duplicate resolution of sliced operand #44504

findleyr opened this issue Feb 22, 2021 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@findleyr
Copy link
Contributor

There appears to be a new panic in go/parser due to code merged from dev.typeparams related to parsing instances (parseIndexOrSliceOrInstance):

Simple repro:

package p

func _() {
  var items []bool
  items[] = false
}

This is invalid syntax, but of course should not cause a panic. Instead, we get:

panic: go/parser internal error: identifier items already declared or resolved [recovered]
        panic: go/parser internal error: identifier items already declared or resolved [recovered]                                                   
        panic: go/parser internal error: identifier items already declared or resolved
                                                                                                                                                     
goroutine 6 [running]:                                                                                                                               
testing.tRunner.func1.2(0x556ea0, 0xc000068ed0)                                                                                                      
        /usr/local/google/home/rfindley/src/go/src/testing/testing.go:1144 +0x34b
testing.tRunner.func1(0xc000001380)                                       
        /usr/local/google/home/rfindley/src/go/src/testing/testing.go:1147 +0x4b6
panic(0x556ea0, 0xc000068ed0)                                                                                                                        
        /usr/local/google/home/rfindley/src/go/src/runtime/panic.go:972 +0x1d4                                                                       
go/parser.ParseFile.func1(0xc00008df40, 0xc000001680, 0xc00008df48)                                                                                  
        /usr/local/google/home/rfindley/src/go/src/go/parser/interface.go:97 +0x1e8
panic(0x556ea0, 0xc000068ed0)                                             
        /usr/local/google/home/rfindley/src/go/src/runtime/panic.go:972 +0x1d4
go/parser.assert(...)                                                     
        /usr/local/google/home/rfindley/src/go/src/go/parser/parser.go:461                                                                           
go/parser.(*parser).tryResolve(0xc000001680, 0x5be898, 0xc000072140, 0x1)                                                                            
        /usr/local/google/home/rfindley/src/go/src/go/parser/parser.go:184 +0x2ec
go/parser.(*parser).resolve(...)                                          
        /usr/local/google/home/rfindley/src/go/src/go/parser/parser.go:206                                                                           
go/parser.(*parser).parseLhsList(0xc000001680, 0xc00008d988, 0x2, 0x2)                                                                               
        /usr/local/google/home/rfindley/src/go/src/go/parser/parser.go:613 +0xcd
go/parser.(*parser).parseSimpleStmt(0xc000001680, 0x1, 0x0, 0x0, 0xc000072100)
        /usr/local/google/home/rfindley/src/go/src/go/parser/parser.go:1958 +0x7b
go/parser.(*parser).parseStmt(0xc000001680, 0x0, 0x0)                                                                                                
        /usr/local/google/home/rfindley/src/go/src/go/parser/parser.go:2513 +0x9a

Thanks to @stamblerre for reporting.

CC @griesemer

@findleyr findleyr added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 22, 2021
@findleyr findleyr added this to the Go1.17 milestone Feb 22, 2021
@findleyr findleyr self-assigned this Feb 22, 2021
@findleyr findleyr added the NeedsFix The path to resolution is known, but the work has not been done. label Feb 22, 2021
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 22, 2021
@gopherbot
Copy link

Change https://golang.org/cl/295151 mentions this issue: go/parser: return ast.BadExpr for missing index operands

@golang golang locked and limited conversation to collaborators Feb 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants