---
title: "impossible-interface-nil-comparison"
description: "Detect interface comparisons made non-nil by a concrete dynamic type."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# impossible-interface-nil-comparison

**Default severity:** `error`

An interface is nil only when both its dynamic type and value are absent.
Storing a typed nil pointer in an interface gives it a concrete dynamic type,
so the interface itself is non-nil.

## Bad

```go
func result() error {
var problem *Problem
return problem // produces a non-nil error interface
}

if result() == nil { // reported as never true
handleSuccess()
}
```

Return an explicit `nil` interface on the success path instead.

## Good

```go
func result(ok bool) error {
	if ok {
		return nil
	}
	return &Problem{}
}
```

Source: https://strider.gempir.com/analyzers/impossible-interface-nil-comparison/index.mdx
