From 7754afb38a413c0d81b12549856fb91fea4e7f8c Mon Sep 17 00:00:00 2001 From: Lilith Hafner Date: Tue, 31 Oct 2023 14:59:44 -0500 Subject: [PATCH 1/2] improve style in Base/experimental.jl --- base/experimental.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/experimental.jl b/base/experimental.jl index abcd52ffcc43f..d7b6099d6657d 100644 --- a/base/experimental.jl +++ b/base/experimental.jl @@ -143,7 +143,7 @@ code to resort to runtime dispatch instead. Supported values are `1`, `2`, `3`, `4`, and `default` (currently equivalent to `3`). """ macro max_methods(n::Int) - 0 < n < 5 || error("We must have that `1 <= max_methods <= 4`, but `max_methods = $n`.") + 1 <= n <= 4 || error("We must have that `1 <= max_methods <= 4`, but `max_methods = $n`.") return Expr(:meta, :max_methods, n) end @@ -156,7 +156,7 @@ for max_methods. This setting is global for the entire generic function (or more the MethodTable). """ macro max_methods(n::Int, fdef::Expr) - 0 < n <= 255 || error("We must have that `1 <= max_methods <= 255`, but `max_methods = $n`.") + 1 <= n <= 255 || error("We must have that `1 <= max_methods <= 255`, but `max_methods = $n`.") (fdef.head === :function && length(fdef.args) == 1) || error("Second argument must be a function forward declaration") return :(typeof($(esc(fdef))).name.max_methods = $(UInt8(n))) end From 5f2391a1ec842b417994b914d4183521b87238ea Mon Sep 17 00:00:00 2001 From: Lilith Hafner Date: Tue, 31 Oct 2023 15:01:48 -0500 Subject: [PATCH 2/2] a few more cases --- base/experimental.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/experimental.jl b/base/experimental.jl index d7b6099d6657d..ccc041b41ec05 100644 --- a/base/experimental.jl +++ b/base/experimental.jl @@ -162,7 +162,7 @@ macro max_methods(n::Int, fdef::Expr) end """ - Experimental.@compiler_options optimize={0,1,2,3} compile={yes,no,all,min} infer={yes,no} max_methods={default,1,2,3,...} + Experimental.@compiler_options optimize={0,1,2,3} compile={yes,no,all,min} infer={yes,no} max_methods={default,1,2,3,4} Set compiler options for code in the enclosing module. Options correspond directly to command-line options with the same name, where applicable. The following options @@ -195,7 +195,7 @@ macro compiler_options(args...) elseif ex.args[1] === :max_methods a = ex.args[2] a = a === :default ? 3 : - a isa Int ? ((0 < a < 5) ? a : error("We must have that `1 <= max_methods <= 4`, but `max_methods = $a`.")) : + a isa Int ? ((1 <= a <= 4) ? a : error("We must have that `1 <= max_methods <= 4`, but `max_methods = $a`.")) : error("invalid argument to \"max_methods\" option") push!(opts.args, Expr(:meta, :max_methods, a)) else