Skip to content

Commit

Permalink
tfuncs: remove unnecessary varargtype check from _builtin_nothrow
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed May 10, 2024
1 parent eabc375 commit 3197075
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2175,10 +2175,12 @@ end
return boundscheck Bool && memtype GenericMemoryRef && order Symbol
end

# Query whether the given builtin is guaranteed not to throw given the argtypes
# Query whether the given builtin is guaranteed not to throw given the `argtypes`.
# `argtypes` can be assumed not to contain varargs.
function _builtin_nothrow(𝕃::AbstractLattice, @nospecialize(f::Builtin), argtypes::Vector{Any},
@nospecialize(rt))
= partialorder(𝕃)
na = length(argtypes)
if f === memoryref
return memoryref_builtin_common_nothrow(argtypes)
elseif f === memoryrefoffset
Expand All @@ -2194,13 +2196,7 @@ function _builtin_nothrow(𝕃::AbstractLattice, @nospecialize(f::Builtin), argt
elseif f === Core._expr
length(argtypes) >= 1 || return false
return argtypes[1] Symbol
end

# These builtins are not-vararg, so if we have varars, here, we can't guarantee
# the correct number of arguments.
na = length(argtypes)
hasvarargtype(argtypes) && return false
if f === Core._typevar
elseif f === Core._typevar
na == 3 || return false
return typevar_nothrow(𝕃, argtypes[1], argtypes[2], argtypes[3])
elseif f === invoke
Expand Down

0 comments on commit 3197075

Please sign in to comment.