Summary
bind.MakeSetterFloat64 documents support for the predeclared signed and unsigned integer types, but passing a uintptr value panics as unsupported.
Class / severity
Robustness / correctness — Low. Correct use of a documented but uncommon numeric type causes an immediate panic.
Contract and valid usage
The MakeSetterFloat64 doc says v may be a setter/getter/static value of "the predeclared signed and unsigned integer types." uintptr is a predeclared unsigned integer type, and the docs list no exclusion for it.
Reproduction
package bind_test
import (
"testing"
"github.com/linkdata/jaws/lib/bind"
)
func TestMakeSetterFloat64AcceptsUintptr(t *testing.T) {
s := bind.MakeSetterFloat64(uintptr(42))
if got := s.JawsGet(nil); got != 42 {
t.Fatalf("JawsGet() = %v, want 42", got)
}
}
The constructor panics with:
expected bind.Setter[float64], bind.Getter[float64] or float64 not uintptr
Root cause
The private numeric constraint omits ~uintptr (lib/bind/setterfloat64.go:19-23), and the dispatch in MakeSetterFloat64 has no makeSetterFloat64for[uintptr] case (lib/bind/setterfloat64.go:199-209). The sanitizer consequently also has no uintptr bounds case.
Impact
Libraries that generically adapt Go numeric fields can crash when a valid uintptr reaches this API, despite relying on its documented supported domain.
Suggested fix
Add ~uintptr to numeric, handle uintptr in sanitizeFloatForT using the platform-width unsigned bound, add makeSetterFloat64for[uintptr], and cover static, Getter, and Setter forms in tests. Alternatively, explicitly exclude uintptr in the exported contract, but that would narrow the current documented domain.
Confidence
Confirmed on main at 6fd13a2.
Summary
bind.MakeSetterFloat64documents support for the predeclared signed and unsigned integer types, but passing auintptrvalue panics as unsupported.Class / severity
Robustness / correctness — Low. Correct use of a documented but uncommon numeric type causes an immediate panic.
Contract and valid usage
The
MakeSetterFloat64doc saysvmay be a setter/getter/static value of "the predeclared signed and unsigned integer types."uintptris a predeclared unsigned integer type, and the docs list no exclusion for it.Reproduction
The constructor panics with:
Root cause
The private
numericconstraint omits~uintptr(lib/bind/setterfloat64.go:19-23), and the dispatch inMakeSetterFloat64has nomakeSetterFloat64for[uintptr]case (lib/bind/setterfloat64.go:199-209). The sanitizer consequently also has nouintptrbounds case.Impact
Libraries that generically adapt Go numeric fields can crash when a valid
uintptrreaches this API, despite relying on its documented supported domain.Suggested fix
Add
~uintptrtonumeric, handleuintptrinsanitizeFloatForTusing the platform-width unsigned bound, addmakeSetterFloat64for[uintptr], and cover static, Getter, and Setter forms in tests. Alternatively, explicitly excludeuintptrin the exported contract, but that would narrow the current documented domain.Confidence
Confirmed on
mainat6fd13a2.