diff --git a/src/abstractsparse.jl b/src/abstractsparse.jl index 37f79e25..d23eebca 100644 --- a/src/abstractsparse.jl +++ b/src/abstractsparse.jl @@ -184,6 +184,13 @@ else end end +macro allowscalar(p) + quote + $(allowscalar)($(esc(p))) + @Core.latestworld + end +end + @inline _is_fixed(::AbstractArray) = false @inline _is_fixed(A::AbstractArray, Bs::Vararg{Any,N}) where N = _is_fixed(A) || (N > 0 && _is_fixed(Bs...)) macro if_move_fixed(a...) diff --git a/test/allowscalar.jl b/test/allowscalar.jl index fa35f35c..306689c5 100644 --- a/test/allowscalar.jl +++ b/test/allowscalar.jl @@ -4,10 +4,10 @@ using Test, SparseArrays A = sprandn(10, 20, 0.9) A[1, 1] = 2 @test A[1, 1] == 2 - SparseArrays.allowscalar(false) + SparseArrays.@allowscalar(false) @test_throws Any A[1, 1] @test_throws Any A[1, 1] = 2 - SparseArrays.allowscalar(true) + SparseArrays.@allowscalar(true) @test A[1, 1] == 2 A[1, 1] = 3 @test A[1, 1] == 3 @@ -15,9 +15,9 @@ using Test, SparseArrays B = sprandn(10, 0.9) B[1] = 2 @test B[1] == 2 - SparseArrays.allowscalar(false) + SparseArrays.@allowscalar(false) @test_throws Any B[1] - SparseArrays.allowscalar(true) + SparseArrays.@allowscalar(true) @test B[1] == 2 B[1] = 3 @test B[1] == 3