github-vet / github-vet/rangeloop-pointer-findings

crides/cgam: core/block.go; 25 LoC

Open
#7,102 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [crides/cgam](https://www.github.com/crides/cgam) at [core/block.go](https://github.com/crides/cgam/blob/c991dcf2bbe0e5701f7ff64de2fd31edbdb24bfe/core/block.go#L26-L50)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.

> range-loop variable i used in defer or goroutine at line 30

[Click here to see the code in its original context.](https://github.com/crides/cgam/blob/c991dcf2bbe0e5701f7ff64de2fd31edbdb24bfe/core/block.go#L26-L50)

Click here to show the 25 line(s) of Go which triggered the analyzer.

```go
for i, op := range b.Ops {
if i == 0 { // Only setup handler once
defer func() {
if err := recover(); err != nil {
offsets := b.Offsets[i]
lnum := offsets[0]
column := offsets[1]
if err != SIGNAL { // Error is a native error; prints header
fmt.Println("\x1b[31mERROR\x1b[0m: Runtime:", to_s(err))
}
fmt.Printf(
` at %s line %d:
%s
%s^
`,
// Line number should start from 1.
b.parser.GetSrc(), lnum + 1,
strings.Split(string(b.parser.content), "\n")[lnum],
strings.Repeat(" ", column - 1))
panic(SIGNAL) // Panics a dummy signal to upper levels to report error
}
}()
}
op.Run(env)
}

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: c991dcf2bbe0e5701f7ff64de2fd31edbdb24bfe

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.