Repository navigation
Conversation
|
bump... |
|
I see the issue, but I'm not completely sure the solution is so straightforward. What worries me is that For example, julia> using ConstructionBase
julia> T = NamedTuple{(:a,), Tuple{Real}};
julia> constructorof(T)(1) isa T
falseThis turns out OK here, because In the long term, I feel like a better fix for the usecase in the testsuite would be to make sure that the type widening is done on the parameters, so that one gets a concrete eltype (eg |
I believe there were discussions about asserting that constructors always return the requested type
This would probably change the return type of regular |
|
Bump... I see this PR as an unambiguous improvement, even though not perfect (ie doesn't get rid of the whole create_instance function). Technically neither regular constructor T(...) nor constructorof(T)(...) guarantee that they return the T type. In practice, I would say the constructorof approach is more reliable: its docs say
Meanwhile, regular T(...) constructors can do whatever processing they want and take arbitrary arguments – not necessarily fields of the type. One doesn't even need to go outside of Base types to break StructArrays. This: also doesn't work now, same as the example in this PR tests. But would work with constructorof(). |
|
Bump... |
|
Another bump |
|
Sorry for the very slow reaction time. I confess I'm hesitant to make fundamental changes such as this one to StructArrays (esp. since I have very limited time to dedicate to the package, so I wouldn't really be able to address any issues that could stem from this). OTOH, this does seem like a practical improvement, and the most important case of concrete element type is preserved, so it should be fine. I'll ask on the arrays Slack if there are strong opinions either way, otherwise I imagine it can be merged. |
Co-authored-by: Mason Protter <mason.protter@icloud.com>
|
bump! |
|
Rebased and merged in #280 |
An example of what gets fixed by this PR is added to runtests.jl: that test would fail before.