Skip to content

Commit 798e62a

Browse files
Type casting for safeInt64
1 parent e73e30a commit 798e62a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/analysis/numericbounds/analyzer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ func checkBoundsWithinTypeRange(pass *analysis.Pass, field *ast.Field, prefix, t
190190
// Kubernetes API conventions enforce JavaScript-safe bounds for int64 (±2^53-1)
191191
// to ensure compatibility with JavaScript clients
192192
if minimum < float64(minSafeInt64) {
193-
pass.Reportf(field.Pos(), "%s has minimum bound %v that is outside the JavaScript-safe int64 range [%d, %d]. Consider using a string type to avoid precision loss in JavaScript clients", prefix, minimum, minSafeInt64, maxSafeInt64)
193+
pass.Reportf(field.Pos(), "%s has minimum bound %v that is outside the JavaScript-safe int64 range [%d, %d]. Consider using a string type to avoid precision loss in JavaScript clients", prefix, minimum, int64(minSafeInt64), int64(maxSafeInt64))
194194
}
195195

196196
if maximum > float64(maxSafeInt64) {
197-
pass.Reportf(field.Pos(), "%s has maximum bound %v that is outside the JavaScript-safe int64 range [%d, %d]. Consider using a string type to avoid precision loss in JavaScript clients", prefix, maximum, minSafeInt64, maxSafeInt64)
197+
pass.Reportf(field.Pos(), "%s has maximum bound %v that is outside the JavaScript-safe int64 range [%d, %d]. Consider using a string type to avoid precision loss in JavaScript clients", prefix, maximum, int64(minSafeInt64), int64(maxSafeInt64))
198198
}
199199
case "float32":
200200
if minimum < float64(minFloat32) || minimum > float64(maxFloat32) {

0 commit comments

Comments
 (0)