Skip to content

Commit

Permalink
fix _builtin_nothrow for arrayset (JuliaLang#46105)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Jul 20, 2022
1 parent 0c03238 commit 028e9ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ end
# Query whether the given builtin is guaranteed not to throw given the argtypes
function _builtin_nothrow(@nospecialize(f), argtypes::Array{Any,1}, @nospecialize(rt))
if f === arrayset
array_builtin_common_nothrow(argtypes, 4) || return true
array_builtin_common_nothrow(argtypes, 4) || return false
# Additionally check element type compatibility
return arrayset_typecheck(argtypes[2], argtypes[3])
elseif f === arrayref || f === const_arrayref
Expand Down
5 changes: 5 additions & 0 deletions test/compiler/effects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,8 @@ let effects = Base.infer_effects(f_setfield_nothrow, ())
#@test Core.Compiler.is_effect_free(effects)
@test Core.Compiler.is_nothrow(effects)
end

# nothrow for arrayset
@test Base.infer_effects((Vector{Int},Int)) do a, i
a[i] = 0 # may throw
end |> !Core.Compiler.is_nothrow

0 comments on commit 028e9ff

Please sign in to comment.