Skip to content

Commit 028e9ff

Browse files
authored
fix _builtin_nothrow for arrayset (#46105)
1 parent 0c03238 commit 028e9ff

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

base/compiler/tfuncs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ end
16971697
# Query whether the given builtin is guaranteed not to throw given the argtypes
16981698
function _builtin_nothrow(@nospecialize(f), argtypes::Array{Any,1}, @nospecialize(rt))
16991699
if f === arrayset
1700-
array_builtin_common_nothrow(argtypes, 4) || return true
1700+
array_builtin_common_nothrow(argtypes, 4) || return false
17011701
# Additionally check element type compatibility
17021702
return arrayset_typecheck(argtypes[2], argtypes[3])
17031703
elseif f === arrayref || f === const_arrayref

test/compiler/effects.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,8 @@ let effects = Base.infer_effects(f_setfield_nothrow, ())
171171
#@test Core.Compiler.is_effect_free(effects)
172172
@test Core.Compiler.is_nothrow(effects)
173173
end
174+
175+
# nothrow for arrayset
176+
@test Base.infer_effects((Vector{Int},Int)) do a, i
177+
a[i] = 0 # may throw
178+
end |> !Core.Compiler.is_nothrow

0 commit comments

Comments
 (0)