File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 11name = " ConstructionBase"
22uuid = " 187b0558-2788-49d3-abe0-74a17ed4e7c9"
33authors = [" Takafumi Arakaki" , " Rafael Schouten" , " Jan Weidner" ]
4- version = " 1.5.5 "
4+ version = " 1.5.6 "
55
66[deps ]
77LinearAlgebra = " 37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ struct FunctionConstructor{F} end
66_isgensym (s:: Symbol ) = occursin (" #" , string (s))
77
88@generated function (fc:: FunctionConstructor{F} )(args... ) where F
9+ isempty (args) && return Expr (:new , F)
10+
911 T = getfield (parentmodule (F), nameof (F))
1012 # We assume all gensym names are anonymous functions
1113 _isgensym (nameof (F)) || return :($ T (args... ))
Original file line number Diff line number Diff line change 246246 end
247247end
248248
249- @testset " Anonymous function constructors" begin
249+ @testset " default function constructors" begin
250250 function multiplyer (a, b)
251251 x -> x * a * b
252252 end
259259 multbc = @inferred constructorof (typeof (mult23))(" b" , " c" )
260260 @inferred multbc (" a" )
261261 @test multbc (" a" ) == " abc"
262+
263+ @test (@inferred constructorof (typeof (sin))()) === sin
264+ f = x -> x^ 2
265+ @test (@inferred constructorof (typeof (f))()) === f
262266end
263267
264268struct Adder{V} <: Function
You can’t perform that action at this time.
0 commit comments