mdempsky/unconvert

Don't warn for type aliases

jdemeyer opened this issue · 0 comments

Consider

type foo = int

func testUnconvert() {
    var x int = 42
    _ = foo(x)
}

unconvert flags this as "unnecessary conversion". But when looking at that code, there may a good reason for the fake "conversion": it could be an implementation detail that foo and int are aliases, it could be that foo and int are used for different purposes.

A good example is a conversion from int32 to rune, which is how I discovered this. Those are aliases, but typically used to represent very different things. Honestly, I didn't even know that they were aliases, until I got those unconvert warnings.