@@ -483,12 +483,24 @@ function_form(short::Bool) = string(short ? "short" : "long", "-form")
483
483
@testset " block expression ($(function_form (short)) anonymous function)" for short in (true , false )
484
484
@testset " (;)" begin
485
485
# The `(;)` syntax was deprecated in 1.4.0-DEV.585 (ce29ec547e) but we can still
486
- # test the behavior with `begin end`.
487
- f, expr = if short
488
- @audit (begin end ) -> nothing
489
- else
490
- @audit function (begin end ) nothing end
491
- end
486
+ # test the behavior with an explicit Expr
487
+ expr = if short
488
+ # `(;) -> nothing`
489
+ Expr (
490
+ :-> ,
491
+ Expr (:block ),
492
+ Expr (:block , LineNumberNode (@__LINE__ , @__FILE__ ), :nothing ),
493
+ )
494
+ else
495
+ # `function (;) nothing end`
496
+ Expr (
497
+ :function ,
498
+ Expr (:block ),
499
+ Expr (:block , LineNumberNode (@__LINE__ , @__FILE__ ), :nothing ),
500
+ )
501
+ end
502
+ f = eval (expr)
503
+
492
504
@test length (methods (f)) == 1
493
505
@test f () === nothing
494
506
@@ -788,8 +800,16 @@ function_form(short::Bool) = string(short ? "short" : "long", "-form")
788
800
789
801
@testset " return-type (long-form anonymous function)" begin
790
802
@testset " (x)::Integer" begin
791
- # Interpreted as `function (x::Integer); x end`
792
- f, expr = @audit function (x):: Integer ; x end
803
+ # Older parsers interpret
804
+ # `function (x)::Integer; x end`
805
+ # as
806
+ # `function (x::Integer); x end`
807
+ expr = Expr (
808
+ :function ,
809
+ Expr (:tuple , Expr (:(:: ), :x , :Integer )),
810
+ Expr (:block , LineNumberNode (@__LINE__ , @__FILE__ ), :x ),
811
+ )
812
+ f = eval (expr)
793
813
@test length (methods (f)) == 1
794
814
@test f (0 ) == 0
795
815
@test_throws MethodError f (0.0 )
0 commit comments