Compiler panic when computing array lengths
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 13.2k
- Forks
- 573
- PR merge metrics
- No merged PRs in 30d
Description
I found following examples that cause the compiler to panic:
Example 1: [compiler panic] Unhandled len type: *types.Array
package main
func a() *[1]byte {
println("side effect")
return nil
}
func main() {
println(len(*a()))
}
Example 2: [compiler panic] interface conversion: interface is int64, not int.
Note that return value of a() is no longer dereferenced.
package main
func a() *[1]byte {
println("side effect")
return nil
}
func main() {
println(len(a()))
}
I expect there are similar problems with cap().
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named in the issue. First reproduce both Go examples and inspect the compiler's handling of len for pointer-to-array values, then check the analogous cap path. Done means both examples compile without a panic and regression coverage verifies the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100