Problem
bind.New and Binder describe T only as comparable, but the default setter evaluates value != *b.ptr. The generic constraint does not guarantee that this comparison cannot panic: any and comparable structs containing interface fields can hold dynamically uncomparable slices, maps, or functions.
package main
import (
"sync"
"github.com/linkdata/jaws/lib/bind"
)
type state struct {
Value any
}
func main() {
var mu sync.RWMutex
value := state{Value: []int{1}}
b := bind.New(&mu, &value)
_ = b.JawsSet(nil, state{Value: []int{2}})
}
This panics with:
runtime error: comparing uncomparable type []int
The relevant implementation is the default equality check in lib/bind/binder.go.
Resolution
Narrow the documented supported domain to strictly comparable bound types. In particular:
any and other interface types are unsupported as T.
- Composite types containing interface-typed fields are unsupported.
- The restriction applies regardless of whether a particular dynamic value would happen to compare successfully.
This is a documentation change, not a request for recovery, reflection-based equality, or another implementation strategy.
Acceptance criteria
Problem
bind.NewandBinderdescribeTonly ascomparable, but the default setter evaluatesvalue != *b.ptr. The generic constraint does not guarantee that this comparison cannot panic:anyand comparable structs containing interface fields can hold dynamically uncomparable slices, maps, or functions.This panics with:
The relevant implementation is the default equality check in
lib/bind/binder.go.Resolution
Narrow the documented supported domain to strictly comparable bound types. In particular:
anyand other interface types are unsupported asT.This is a documentation change, not a request for recovery, reflection-based equality, or another implementation strategy.
Acceptance criteria
Newdocuments thatTmust be strictly comparable and names the panic risk behind the broadercomparableconstraint.Binderand its defaultJawsSetLockedbehavior describe the same supported domain.any, other interface types, and composites containing interfaces as unsupported.go doc ./lib/bind Newandgo doc ./lib/bind Binderexpose the restriction clearly.