Skip to content

Fix return type for setindex!(::SizedArray, ...) #1007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2022

Conversation

mcabbott
Copy link
Collaborator

This fixes the following:

julia> using StaticArrays

julia> sa = SizedVector{2}([1,2]);

julia> setindex!(sa, 99, 1)  # doesn't return the array itself, like Base does
2-element Vector{Int64}:
 99
  2

julia> sa
2-element SizedVector{2, Int64, Vector{Int64}} with indices SOneTo(2):
 99
  2

For a SizedMatrix there is no problem, nor for an MArray. But this also adds tests for those cases.

@mcabbott
Copy link
Collaborator Author

Motivated, BTW, by the following hack to solve #1005:

canset(x::AbstractArray) = canset(typeof(x))
canset(::Type{T}) where {T<:AbstractArray} = Base._return_type(setindex!, Tuple{T, eltype(T), Int}) == T

which fails for SizedVector.

@mcabbott
Copy link
Collaborator Author

I forgot I had a merge button here...

Thoughts on merging despite CI errors, like this (below)? Perhaps similar to #999 but not identitcal.

185
Test Summary:    | Pass  Total
[186](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:186)
QR decomposition |  500    500
[187](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:187)
Test Summary:       | Pass  Total
[188](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:188)
QR method ambiguity |    3      3
[189](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:189)
terminate called after throwing an instance of 'std::bad_alloc'
[190](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:190)
  what():  std::bad_alloc
[191](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:191)

[192](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:192)
signal (6): Aborted
[193](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:193)
in expression starting at /home/runner/work/StaticArrays.jl/StaticArrays.jl/test/chol.jl:4
[194](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:194)
__kernel_vsyscall at linux-gate.so.1 (unknown line)
[195](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:195)
gsignal at /lib32/libc.so.6 (unknown line)
[196](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:196)
abort at /lib32/libc.so.6 (unknown line)
[197](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:197)
unknown function (ip: 0xf2cbb9c9)
[198](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:198)
unknown function (ip: 0xf2cc9e57)
[199](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:199)
_ZSt9terminatev at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libstdc++.so.6 (unknown line)
[200](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:200)
__cxa_throw at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libstdc++.so.6 (unknown line)
[201](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:201)
unknown function (ip: 0xf2cbb53f)
[202](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:202)
unknown function (ip: 0xf79becbf)
[203](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:203)
unknown function (ip: 0xf7994592)
[204](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:204)
unknown function (ip: 0xf79b2739)
[205](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:205)
unknown function (ip: 0xf79b2bb4)
[206](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:206)
unknown function (ip: 0xf79b331c)
[207](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:207)
unknown function (ip: 0xf7a6a569)
[208](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:208)
unknown function (ip: 0xf7a6bd58)
[209](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:209)
unknown function (ip: 0xf79d9ae4)
[210](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:210)
jl_apply_generic at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libjulia-internal.so.1 (unknown line)
[211](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:211)
macro expansion at /buildworker/worker/package_linux32/build/usr/share/julia/stdlib/v1.7/Test/src/Test.jl:445 [inlined]
[212](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:212)
macro expansion at /home/runner/work/StaticArrays.jl/StaticArrays.jl/test/chol.jl:50 [inlined]
[213](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:213)
macro expansion at /buildworker/worker/package_linux32/build/usr/share/julia/stdlib/v1.7/Test/src/Test.jl:1283 [inlined]
[214](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:214)
macro expansion at /home/runner/work/StaticArrays.jl/StaticArrays.jl/test/chol.jl:47 [inlined]
[215](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:215)
macro expansion at /buildworker/worker/package_linux32/build/usr/share/julia/stdlib/v1.7/Test/src/Test.jl:1283 [inlined]
[216](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:216)
top-level scope at /home/runner/work/StaticArrays.jl/StaticArrays.jl/test/chol.jl:5
[217](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:217)
unknown function (ip: 0xf7a19568)
[218](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:218)
unknown function (ip: 0xf7a188b2)
[219](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:219)
jl_toplevel_eval at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libjulia-internal.so.1 (unknown line)
[220](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:220)
jl_toplevel_eval_in at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libjulia-internal.so.1 (unknown line)
[221](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:221)
eval at ./boot.jl:373 [inlined]
[222](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:222)
include_string at ./loading.jl:1196
[223](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:223)
jl_apply_generic at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libjulia-internal.so.1 (unknown line)
[224](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:224)
_include at ./loading.jl:1253
[225](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:225)
include at ./client.jl:451 [inlined]
[226](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:226)
addtests at /home/runner/work/StaticArrays.jl/StaticArrays.jl/test/runtests.jl:20
[227](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:227)
jl_apply_generic at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libjulia-internal.so.1 (unknown line)
[228](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:228)
unknown function (ip: 0xf79f83a5)
[229](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:229)
unknown function (ip: 0xf79f7e0b)
[230](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:230)
unknown function (ip: 0xf79f8a64)
[231](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:231)
unknown function (ip: 0xf79f97e4)
[232](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:232)
unknown function (ip: 0xf7a186d2)
[233](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:233)
unknown function (ip: 0xf7a188b2)
[234](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:234)
jl_toplevel_eval at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libjulia-internal.so.1 (unknown line)
[235](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:235)
jl_toplevel_eval_in at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libjulia-internal.so.1 (unknown line)
[236](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:236)
eval at ./boot.jl:373 [inlined]
[237](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:237)
include_string at ./loading.jl:1196
[238](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:238)
jl_apply_generic at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libjulia-internal.so.1 (unknown line)
[239](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:239)
_include at ./loading.jl:1253
[240](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:240)
include at ./client.jl:451
[241](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:241)
jl_apply_generic at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libjulia-internal.so.1 (unknown line)
[242](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:242)
unknown function (ip: 0xf79f83a5)
[243](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:243)
unknown function (ip: 0xf79f7e0b)
[244](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:244)
unknown function (ip: 0xf79f8a64)
[245](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:245)
unknown function (ip: 0xf79f97e4)
[246](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:246)
unknown function (ip: 0xf7a186d2)
[247](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:247)
unknown function (ip: 0xf7a188b2)
[248](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:248)
jl_toplevel_eval at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libjulia-internal.so.1 (unknown line)
[249](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:249)
jl_toplevel_eval_in at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libjulia-internal.so.1 (unknown line)
[250](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:250)
eval at ./boot.jl:373 [inlined]
[251](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:251)
exec_options at ./client.jl:268
[252](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:252)
_start at ./client.jl:495
[253](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:253)
jfptr__start_19044.clone_1 at /opt/hostedtoolcache/julia/1.7.2/x86/lib/julia/sys.so (unknown line)
[254](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:254)
jl_apply_generic at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libjulia-internal.so.1 (unknown line)
[255](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:255)
unknown function (ip: 0xf7a3d9e1)
[256](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:256)
jl_repl_entrypoint at /opt/hostedtoolcache/julia/1.7.2/x86/bin/../lib/julia/libjulia-internal.so.1 (unknown line)
[257](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:257)
main at /buildworker/worker/package_linux32/build/cli/loader_exe.c:42
[258](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:258)
__libc_start_main at /lib32/libc.so.6 (unknown line)
[259](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:259)
_start at /opt/hostedtoolcache/julia/1.7.2/x86/bin/julia (unknown line)
[260](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:260)
Allocations: 2955506414 (Pool: 2954885582; Big: 620832); GC: 960
[261](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:261)
ERROR: Package StaticArrays errored during testing (received signal: 6)
[262](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:262)
Stacktrace:
[263](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:263)
 [1] pkgerror(msg::String)
[264](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:264)
   @ Pkg.Types /opt/hostedtoolcache/julia/1.7.2/x86/share/julia/stdlib/v1.7/Pkg/src/Types.jl:68
[265](https://github.com/JuliaArrays/StaticArrays.jl/runs/5347561905?check_suite_focus=true#step:5:265)
 [2] test(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; coverage::Bool, julia_args::Cmd, test_args::Cmd, test_fn::Nothing, force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool)

@mateuszbaran
Copy link
Collaborator

Thoughts on merging despite CI errors, like this (below)? Perhaps similar to #999 but not identitcal.

This is a random out-of-memory error, they happen in StaticArrays.jl on x86 systems sometimes. I just re-run tests when it happens.

@mcabbott mcabbott merged commit df49828 into JuliaArrays:master Feb 27, 2022
@mcabbott mcabbott deleted the setindex branch February 27, 2022 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants