File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 27
27
28
28
# # native julia error handling ##
29
29
30
+ # This is `Experimental.@max_methods 2 function error end`, which is not available at this point in bootstrap.
31
+ # NOTE It is important to always be able to infer the return type of `error` as `Union{}`,
32
+ # but there's a hitch when a package globally sets `@max_methods 1` and it causes inference
33
+ # for `error(::Any)` to fail (JuliaLang/julia#54029).
34
+ # This definition site `@max_methods 2` setting overrides any global `@max_methods 1` settings
35
+ # on package side, guaranteeing that return type inference on `error` is successful always.
36
+ function error end
37
+ typeof (error). name. max_methods = UInt8 (2 )
38
+
30
39
"""
31
40
error(message::AbstractString)
32
41
Original file line number Diff line number Diff line change 127
127
visited = test_exceptions (Base)
128
128
test_exceptions (Core, visited)
129
129
end
130
+
131
+ # inference quality test for `error`
132
+ @test Base. infer_return_type (error, (Any,)) === Union{}
133
+ @test Base. infer_return_type (xs-> error (xs... ), (Vector{Any},)) === Union{}
134
+ module Issue54029
135
+ export raise54029
136
+ Base. Experimental. @max_methods 1
137
+ raise54029 (x) = error (x)
138
+ end
139
+ using . Issue54029
140
+ @test Base. infer_return_type (raise54029, (Any,)) === Union{}
141
+ @test Base. infer_return_type (xs-> raise54029 (xs... ), (Vector{Any},)) === Union{}
You can’t perform that action at this time.
0 commit comments