• S
    Don't assume all hashes are from multiparameter assignment in `composed_of` · b63d532f
    Sean Griffin 提交于
    So this bug is kinda funky. The code path is basically "if we weren't passed an
    instance of the class we compose to, and we have a converter, call that".
    Ignoring the hash case for a moment, everything after that was roughly intended
    to be the "else" clause, meaning that we are expected to have an instance of
    the class we compose to. Really, we should be blowing up in that case, as we
    can give a much better error message than what they user will likely get (e.g.
    `NameError: No method first for String` or something). Still, Ruby is duck
    typed, so if the object you're assigning responds to the same methods as the
    type you compose to, knock yourself out.
    
    The hash case was added in 36e9be85 to remove a bunch of special cased code from
    multiparameter assignment. I wrongly assumed that the only time we'd get a hash
    there is in that case. Multiparameter assignment will construct a very specific
    hash though, where the keys are integers, and we will have a set of keys
    covering `1..part.size` exactly. I'm pretty sure this could actually be passed
    around as an array, but that's a different story. Really I should convert this
    to something like `class MultiParameterAssignment < Hash; end`, which I might
    do soon. However for a change that I'm willing to backport to 4-2-stable, this
    is what I want to go with for the time being.
    
    Fixes #25978
    b63d532f
aggregations.rb 13.7 KB