Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -929,29 +929,31 @@ function getfield_boundscheck((; fargs, argtypes)::ArgInfo) # Symbol
elseif length(argtypes) == 4
fargs !== nothing && (farg = fargs[4])
boundscheck = argtypes[4]
isvarargtype(boundscheck) && return :unknown
isvarargtype(boundscheck) && return :unsafe
if widenconst(boundscheck) === Symbol
return :on
end
elseif length(argtypes) == 5
fargs !== nothing && (farg = fargs[5])
boundscheck = argtypes[5]
else
return :unknown
return :unsafe
end
isvarargtype(boundscheck) && return :unknown
isvarargtype(boundscheck) && return :unsafe
boundscheck = widenconditional(boundscheck)
if widenconst(boundscheck) === Bool
if isa(boundscheck, Const)
return boundscheck.val::Bool ? :on : :off
elseif farg !== nothing && isexpr(farg, :boundscheck)
return :boundscheck
end
return :unknown
end
return :unknown
return :unsafe
end

function getfield_nothrow(𝕃::AbstractLattice, arginfo::ArgInfo, boundscheck::Symbol=getfield_boundscheck(arginfo))
boundscheck === :unsafe && return false
(;argtypes) = arginfo
ordering = Const(:not_atomic)
if length(argtypes) == 4
Expand All @@ -960,7 +962,7 @@ function getfield_nothrow(𝕃::AbstractLattice, arginfo::ArgInfo, boundscheck::
ordering = argtypes[4]
end
elseif length(argtypes) == 5
ordering = argtypes[5]
ordering = argtypes[4]
elseif length(argtypes) != 3
return false
end
Expand Down
19 changes: 19 additions & 0 deletions test/compiler/effects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,25 @@ end |> Core.Compiler.is_nothrow
getfield(t, i, false) # invalid name type
end |> !Core.Compiler.is_nothrow

@test Base.infer_effects((Some{Any},)) do some
getfield(some, 1, :not_atomic)
end |> Core.Compiler.is_nothrow
@test Base.infer_effects((Some{Any},)) do some
getfield(some, 1, :invalid_atomic_spec)
end |> !Core.Compiler.is_nothrow
@test Base.infer_effects((Some{Any},Bool)) do some, boundscheck
getfield(some, 1, boundscheck)
end |> Core.Compiler.is_nothrow
@test Base.infer_effects((Some{Any},Bool)) do some, boundscheck
getfield(some, 1, :not_atomic, boundscheck)
end |> Core.Compiler.is_nothrow
@test Base.infer_effects((Some{Any},Bool)) do some, boundscheck
getfield(some, 1, :invalid_atomic_spec, boundscheck)
end |> !Core.Compiler.is_nothrow
@test Base.infer_effects((Some{Any},Any)) do some, boundscheck
getfield(some, 1, :not_atomic, boundscheck)
end |> !Core.Compiler.is_nothrow

@test Core.Compiler.is_consistent(Base.infer_effects(setindex!, (Base.RefValue{Int}, Int)))

# :inaccessiblememonly effect
Expand Down