Here's a dictionary where values contain collections of length not equal to 1. Broadcasting only should result in an error, but I get the first element instead:
which further leads to the @inbounds assertion within the map! implementation, and the @propagate_inbounds within gettokenvalue(d::BroadcastedDictionary, t). This removes the @boundscheck within only when only is inlined. So while we have the expected:
julia> Dictionaries.gettokenvalue(bc, (0,1))
ERROR: ArgumentError: Collection has multiple elements, must contain exactly 1 element
Stacktrace:
[1] only
@ ./iterators.jl:1327 [inlined]
When this is optimized within an inbounds context (within map!), the bounds check disappears:
Here's a dictionary where values contain collections of length not equal to 1. Broadcasting
only
should result in an error, but I get the first element instead:Digging a little through the dispatch chain leads to
which further leads to the
@inbounds
assertion within themap!
implementation, and the@propagate_inbounds
withingettokenvalue(d::BroadcastedDictionary, t)
. This removes the@boundscheck
withinonly
whenonly
is inlined. So while we have the expected:When this is optimized within an inbounds context (within
map!
), the bounds check disappears: