exercism / go-analyzer

GNU Affero General Public License v3.0
10 stars 12 forks source link

raindrops: panic on for loop without condition #7

Open bitfield opened 5 years ago

bitfield commented 5 years ago

This solution breaks Exalysis, and presumably now also go-analyzer. Here's the problem:

    for {
        ...
    }

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

        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
tehsphinx commented 5 years ago

Test case added in feature/raindrops branch