File tree Expand file tree Collapse file tree 4 files changed +38
-1
lines changed Expand file tree Collapse file tree 4 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 1
1
name = " Compat"
2
2
uuid = " 34da2185-b29b-5c13-b0c7-acf172513d20"
3
- version = " 3.34 .0"
3
+ version = " 3.35 .0"
4
4
5
5
[deps ]
6
6
Base64 = " 2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ changes in `julia`.
54
54
55
55
## Supported features
56
56
57
+ * ` Returns(value) ` returns ` value ` for any arguments ([ #39794 ] ) (since Compat 3.35)
58
+
57
59
* The function ` current_exceptions() ` has been added to get the current
58
60
exception stack. Julia-1.0 lacks runtime support for full execption stacks,
59
61
so we return only the most recent exception in that case. ([ #29901 ] ) (since
@@ -270,3 +272,4 @@ Note that you should specify the correct minimum version for `Compat` in the
270
272
[ #35316 ] : https://github.com/JuliaLang/julia/pull/35316
271
273
[ #41076 ] : https://github.com/JuliaLang/julia/pull/41076
272
274
[ #34331 ] : https://github.com/JuliaLang/julia/pull/34331
275
+ [ #39794 ] : https://github.com/JuliaLang/julia/pull/39794
Original file line number Diff line number Diff line change @@ -1102,6 +1102,25 @@ if VERSION < v"1.7.0-DEV.1106"
1102
1102
export current_exceptions
1103
1103
end
1104
1104
1105
+ # https://github.com/JuliaLang/julia/pull/39794
1106
+ if VERSION < v " 1.7.0-DEV.793"
1107
+ export Returns
1108
+
1109
+ struct Returns{V} <: Function
1110
+ value:: V
1111
+ Returns {V} (value) where {V} = new {V} (value)
1112
+ Returns (value) = new {Core.Typeof(value)} (value)
1113
+ end
1114
+
1115
+ (obj:: Returns )(args... ; kw... ) = obj. value
1116
+ function Base. show (io:: IO , obj:: Returns )
1117
+ show (io, typeof (obj))
1118
+ print (io, " (" )
1119
+ show (io, obj. value)
1120
+ print (io, " )" )
1121
+ end
1122
+ end
1123
+
1105
1124
include (" iterators.jl" )
1106
1125
include (" deprecated.jl" )
1107
1126
Original file line number Diff line number Diff line change @@ -1144,3 +1144,18 @@ end
1144
1144
""" , sprint (show, excs))
1145
1145
end
1146
1146
end
1147
+
1148
+ # https://github.com/JuliaLang/julia/pull/39794
1149
+ @testset " Returns" begin
1150
+ @test @inferred (Returns (1 )() ) === 1
1151
+ @test @inferred (Returns (1 )(23 ) ) === 1
1152
+ @test @inferred (Returns (" a" )(2 ,3 )) == " a"
1153
+ @test @inferred (Returns (1 )(x= 1 , y= 2 )) === 1
1154
+ @test @inferred (Returns (Int)()) === Int
1155
+ @test @inferred (Returns (Returns (1 ))()) === Returns (1 )
1156
+ f = @inferred Returns (Int)
1157
+ @inferred f (1 ,2 )
1158
+ val = [1 ,2 ,3 ]
1159
+ @test Returns (val)(1 ) === val
1160
+ @test sprint (show, Returns (1.0 )) == " Returns{Float64}(1.0)"
1161
+ end
You can’t perform that action at this time.
0 commit comments