Skip to content

Commit

Permalink
effect: mark Core.TypeofVararg as ismutationfree (JuliaLang#52586)
Browse files Browse the repository at this point in the history
Found in
https://buildkite.com/julialang/julia-master/builds/31309#018c7f0b-aada-4017-bb2f-44001593ac6b.
On master keyword call might taint `inaccessiblememonly`.
MWE: 
```julia
julia> foo(; kws...) = 1
foo (generic function with 1 method)

julia> Base.infer_effects(foo, Tuple{})
(+c,+e,+n,+t,+s,!m,+u)
```
which is caused by
```julia
julia> Base.infer_effects(()->Vararg)
(+c,+e,+n,+t,+s,!m,+u)
```

Co-authored-by: Shuhei Kadowaki <[email protected]>
  • Loading branch information
N5N3 and aviatesk committed Dec 21, 2023
1 parent 0cac28c commit 631e7ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2785,6 +2785,7 @@ void jl_init_types(void) JL_GC_DISABLED
XX(vararg);
// It seems like we probably usually end up needing the box for kinds (often used in an Any context), so force it to exist
jl_vararg_type->name->mayinlinealloc = 0;
jl_vararg_type->ismutationfree = 1;

jl_svec_t *anytuple_params = jl_svec(1, jl_wrap_vararg((jl_value_t*)jl_any_type, (jl_value_t*)NULL, 0));
jl_anytuple_type = jl_new_datatype(jl_symbol("Tuple"), core, jl_any_type, anytuple_params,
Expand Down
3 changes: 3 additions & 0 deletions test/compiler/effects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,9 @@ end
@test set_a52531!(1) == 1
@test get_a52531() == 1

@test Core.Compiler.is_inaccessiblememonly(Base.infer_effects(identityidentity, Tuple{Any}))
@test Core.Compiler.is_inaccessiblememonly(Base.infer_effects(()->Vararg, Tuple{}))

# pointerref nothrow for invalid pointer
@test !Core.Compiler.intrinsic_nothrow(Core.Intrinsics.pointerref, Any[Type{Ptr{Vector{Int64}}}, Int, Int])
@test !Core.Compiler.intrinsic_nothrow(Core.Intrinsics.pointerref, Any[Type{Ptr{T}} where T, Int, Int])

0 comments on commit 631e7ef

Please sign in to comment.