Closed cscherrer closed 2 years ago
For context, I'm mainly using Accessors.jl, and wanted a Lens!!
to make things work similarly to BangBang. Using BangBang directly gives the above error, but it seems to fix things if I instead do
@inline function Accessors.set(o, l::Lens!!{PropertyLens{prop}}, val) where {prop}
if ismutable(o)
setproperty!(o, prop, val)
else
setproperties(o, NamedTuple{(prop,)}((val,)))
end
end
Maybe a similar change can help BangBang?
Uh, I totally forgot that I haven't still made BangBang compatible with Accessors
For the problem in the OP, I think we need to help inference somewhere to constprop :a
.
BTW, for testing API like setproperty!!
that requries constprop, you'd need to create a function like f!!(nt) = setproperty!!(nt, :a, 3)
and pass it to the inference. IIUC it's the same for JET.
I haven't worked through the details, but I'd think this can be made to dispatch statically: