Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

rules/sdk: just aliasing an integer type prevents it from being checked #57

@odeke-em

Description

@odeke-em

This code embarrassingly never triggers an overflow check

package main
import "math"
type in = int
func main() {
	v := uint64(math.MaxUint64)
	_ = in(v)
}

and the reason is because the check if the end type is an integer is quite brittle per

intCast := strings.HasPrefix(fun.Name, "int") || strings.HasPrefix(fun.Name, "uint")

but really we should get the final type by doing this and check if it is an int cast

destType := ctx.Info.TypeOf(fun).Underlying()
intCast := hasAnyPrefix(destType.String(), "int", "uint")

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions