dgryski / semgrep-go

Go rules for semgrep and go-ruleguard
MIT License
457 stars 37 forks source link

false positive in unconvert with blank (_) separator in integer number literals #29

Closed komuw closed 3 years ago

komuw commented 3 years ago

With the following

package main

import "time"

func hello(x time.Duration) {}

func main() {
    x := time.Duration(10_000)
    hello(x)
}

we get the error;

/tmp/ok/main.go:8:7: unconvert: unnecessary conversion (rules.go:30)
7   func main() {
8       x := time.Duration(10_000)
9       hello(x)

However if we change variable x so that it doesn't contain an underscore

x := time.Duration(10000)

then we no longer get an error