exercism / exercism/go-analyzer

raindrops: panic on for loop without condition

Open
#7 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
10
Forks
11
PR merge metrics
No merged PRs in 30d

Description

[This solution](https://exercism.io/mentor/solutions/53eec9710daf40d7b529b5b6083ac2a0) breaks Exalysis, and presumably now also `go-analyzer`. Here's the problem:

```go
for {
...
}
```

In `examExtensiveForLoop`, this code assumes that every `for` loop will have a condition:

```go
if loop.Cond().FindFirstByName(paramName) != nil {
...
}
```

In this case, `loop.Cond()` is nil:

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xa0 pc=0x1466eed]

goroutine 1 [running]:
github.com/exercism/exalysis/track/raindrops.examExtensiveForLoop(0xc0000d0140, 0xc0001d20c0)
/Users/john/git/bitfield/exalysis/track/raindrops/raindrops.go:116 +0x16d
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.