gopherjs icon indicating copy to clipboard operation
gopherjs copied to clipboard

Compiler panic when computing array lengths

Open nevkontakte opened this issue 3 years ago • 0 comments

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().

nevkontakte avatar Sep 11 '21 17:09 nevkontakte