File tree Expand file tree Collapse file tree 3 files changed +8
-1
lines changed Expand file tree Collapse file tree 3 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ Julia v1.6 Release Notes
4
4
New language features
5
5
---------------------
6
6
7
+ * Types written with ` where ` syntax can now be used to define constructors, e.g.
8
+ ` (Foo{T} where T)(x) = ... ` .
7
9
8
10
Language changes
9
11
----------------
Original file line number Diff line number Diff line change 1111
1111
(and (not (any kwarg? argl)) (not (and (pair? argl)
1112
1112
(pair? (car argl))
1113
1113
(eq? (caar argl) 'parameters ))))))
1114
- (name (if (or (decl? name) (and (pair? name) (eq? (car name) 'curly )))
1114
+ (name (if (or (decl? name) (and (pair? name) (memq (car name) ' ( curly where) )))
1115
1115
#f name)))
1116
1116
(expand-forms
1117
1117
(method-def-expr name sparams argl body rett))))
Original file line number Diff line number Diff line change @@ -4708,6 +4708,11 @@ let ft = Base.datatype_fieldtypes
4708
4708
@test ! isdefined (ft (B12238. body. body)[1 ], :instance ) # has free type vars
4709
4709
end
4710
4710
4711
+ # `where` syntax in constructor definitions
4712
+ (A12238{T} where T<: Real )(x) = 0
4713
+ @test A12238 {<:Real} (0 ) == 0
4714
+ @test_throws MethodError A12238 {<:Integer} (0 )
4715
+
4711
4716
# issue #16315
4712
4717
let a = Any[]
4713
4718
@noinline f () = a[end ]
You can’t perform that action at this time.
0 commit comments