File tree Expand file tree Collapse file tree 4 files changed +20
-5
lines changed Expand file tree Collapse file tree 4 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
15
15
16
16
[compat ]
17
17
Adapt = " 2.0, 3.0"
18
- GPUArraysCore = " = 0.1.4 "
18
+ GPUArraysCore = " = 0.1.5 "
19
19
LLVM = " 3.9, 4, 5"
20
20
Reexport = " 1"
21
21
julia = " 1.6"
Original file line number Diff line number Diff line change 1
1
name = " GPUArraysCore"
2
2
uuid = " 46192b85-c4d5-4398-a991-12ede77f4527"
3
3
authors = [" Tim Besard <tim.besard@gmail.com>" ]
4
- version = " 0.1.4 "
4
+ version = " 0.1.5 "
5
5
6
6
[deps ]
7
7
Adapt = " 79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Original file line number Diff line number Diff line change @@ -110,6 +110,16 @@ function assertscalar(op = "operation")
110
110
return
111
111
end
112
112
113
+ # Like a try-finally block, except without introducing the try scope
114
+ # NOTE: This is deprecated and should not be used from user logic. A proper solution to
115
+ # this problem will be introduced in https://github.com/JuliaLang/julia/pull/39217
116
+ macro __tryfinally (ex, fin)
117
+ Expr (:tryfinally ,
118
+ :($ (esc (ex))),
119
+ :($ (esc (fin)))
120
+ )
121
+ end
122
+
113
123
"""
114
124
@allowscalar() begin
115
125
# code that can use scalar indexing
@@ -121,9 +131,11 @@ See also: [`allowscalar`](@ref).
121
131
"""
122
132
macro allowscalar (ex)
123
133
quote
124
- task_local_storage (:ScalarIndexing , ScalarAllowed) do
125
- $ (esc (ex))
126
- end
134
+ local tls_value = get (task_local_storage (), :ScalarIndexing , nothing )
135
+ task_local_storage (:ScalarIndexing , ScalarAllowed)
136
+ @__tryfinally ($ (esc (ex)),
137
+ isnothing (tls_value) ? delete! (task_local_storage (), :ScalarIndexing )
138
+ : task_local_storage (:ScalarIndexing , tls_value))
127
139
end
128
140
end
129
141
Original file line number Diff line number Diff line change 17
17
end
18
18
19
19
@test_throws ErrorException x[]
20
+
21
+ @allowscalar y = 42
22
+ @test y == 42
20
23
end
21
24
22
25
@allowscalar @testset " getindex with $T " for T in eltypes
You can’t perform that action at this time.
0 commit comments