Skip to content

Unchecked nil pointer dereference when calling a result that is a type function #2114

@dlsniper

Description

@dlsniper
package main

func hello() func() string {
    return nil
}

func main() {
    hello()() // This should have a warning as it will crash when hello() returns nil
}

Running the example above:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0xffffffff addr=0x0 pc=0x20016]

goroutine 1 [running]:
main.main()
    /tmp/sandbox522197955/main.go:8 +0x16

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions