Skip to content

Commit abce98e

Browse files
authored
Assume effects (#783)
* Compat for `@assume_effects`
1 parent 6e1b40c commit abce98e

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Compat"
22
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
3-
version = "4.3.0"
3+
version = "4.4.0"
44

55
[deps]
66
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ changes in `julia`.
7070

7171
## Supported features
7272

73+
* `Compat.@assume_effects setting... ex` overrides the compiler's effect modeling for the method definition `ex` on Julia versions that support this feature. Julia version without support just pass back `ex`. ([#43852]) (since Compat 4.4.0)
74+
7375
* `div`, `lcm`, `gcd`, `/`, `rem`, and `mod` will `promote` heterogenous `Dates.Period`s ([`@bdf9ead9`]). (since Compat 4.3.0)
7476

7577
* `stack` combines a collection of slices into one array ([#43334]). (since Compat 4.2.0)

src/Compat.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ end
5151
end
5252
end
5353

54+
# https://github.com/JuliaLang/julia/pull/43852
55+
@static if VERSION < v"1.8.0-DEV.1484"
56+
macro assume_effects(args...)
57+
esc(last(args))
58+
end
59+
else
60+
using Base: @assume_effects
61+
end
62+
5463
if VERSION < v"1.7.0-DEV.119"
5564
# Part of:
5665
# https://github.com/JuliaLang/julia/pull/35316

test/runtests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@ end
236236
@test sprint(show, Returns(1.0)) == "Returns{Float64}(1.0)"
237237
end
238238

239+
# https://github.com/JuliaLang/julia/pull/43852
240+
@testset "@assume_effects" begin
241+
# ensure proper macro hygiene across versions
242+
Compat.@assume_effects :total foo() = true
243+
Compat.@assume_effects bar() = true
244+
@test foo()
245+
@test bar()
246+
end
247+
239248
# https://github.com/JuliaLang/julia/pull/42125
240249
@testset "@constprop" begin
241250
Compat.@constprop :aggressive aggf(x) = Symbol(x)

0 commit comments

Comments
 (0)