Thanks Ian, I have filed the bug report : https://github.com/golang/go/issues/27356
On Wednesday, August 29, 2018 at 9:22:49 PM UTC-4, Ian Lance Taylor wrote: > > On Wed, Aug 29, 2018 at 6:16 PM, <tayl...@gmail.com <javascript:>> > wrote: > > Sorry, should have mentioned I came across this in go1.11 but I have not > > validated that it is not an issue in earlier releases. > > I can't find anything similar in the issue tracker. Please do file a > bug report at https://golang.org/issue. Thanks. > > Ian > > > > On Wednesday, August 29, 2018 at 9:14:03 PM UTC-4, Chris Taylor wrote: > >> > >> Hi, > >> > >> Before reporting this bug I thought I would post here to confirm that > it > >> has not been covered already. > >> > >> If a function argument hides a built-in function and there is an > attempt > >> to call the built-in function the compiler will crash with no > indication of > >> where it was in the compilation process, which makes it hard to find in > a > >> large codebase. > >> > >> Here is a simple repo of the issue > >> > >> package main > >> > >> var a = []byte{1,2,3} > >> > >> func bug(len int) bool { > >> return len < len(a) > >> } > >> > >> func main() { > >> println(bug(5)) > >> } > >> > >> Here the argument len hides the built-in function len, and in that same > >> function a call is made to the function len. The expected result would > be a > >> compiler error > >> > >>> cannot call non-function len (type int) > >> > >> > >> The actual result is > >> > >>> panic: runtime error: invalid memory address or nil pointer > dereference > >>> [signal 0xc0000005 code=0x0 addr=0x70 pc=0xb94675] > >>> goroutine 1 [running]: > >>> cmd/compile/internal/gc.typecheck1(0xc000352580, 0x2, 0xc00033fa40) > >>> c:/go/src/cmd/compile/internal/gc/typecheck.go:1270 +0x3ed5 > >>> cmd/compile/internal/gc.typecheck(0xc000352580, 0x2, 0xc00033fa40) > >>> c:/go/src/cmd/compile/internal/gc/typecheck.go:238 +0x6b4 > >>> cmd/compile/internal/gc.typecheck1(0xc000352600, 0x12, 0xc000084998) > >>> c:/go/src/cmd/compile/internal/gc/typecheck.go:585 +0x2cce > >>> cmd/compile/internal/gc.typecheck(0xc000352600, 0x12, 0xc0000849d8) > >>> c:/go/src/cmd/compile/internal/gc/typecheck.go:238 +0x6b4 > >>> cmd/compile/internal/gc.typecheckslice(0xc0000885d0, 0x1, 0x1, 0x12) > >>> c:/go/src/cmd/compile/internal/gc/typecheck.go:68 +0x57 > >>> cmd/compile/internal/gc.typecheck1(0xc000352680, 0x1, 0xcbf373) > >>> c:/go/src/cmd/compile/internal/gc/typecheck.go:2065 +0xadd4 > >>> cmd/compile/internal/gc.typecheck(0xc000352680, 0x1, 0x3) > >>> c:/go/src/cmd/compile/internal/gc/typecheck.go:238 +0x6b4 > >>> cmd/compile/internal/gc.typecheckslice(0xc0000885d8, 0x1, 0x1, 0x1) > >>> c:/go/src/cmd/compile/internal/gc/typecheck.go:68 +0x57 > >>> cmd/compile/internal/gc.Main(0xcdea30) > >>> c:/go/src/cmd/compile/internal/gc/main.go:518 +0x20d0 > >>> main.main() > >>> c:/go/src/cmd/compile/main.go:51 +0x9d > >> > >> > >> Best Regards, > >> > >> Chris > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to golang-nuts...@googlegroups.com <javascript:>. > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.