Skip to content

Commit

Permalink
inference: add basic support for :globaldecl expressions (#55144)
Browse files Browse the repository at this point in the history
Following up #54773.
Required for external abstract interpreters that may run inference on
arbitrary top-level thunks.
  • Loading branch information
aviatesk authored Jul 16, 2024
1 parent 946301c commit 1c7ce01
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2705,6 +2705,8 @@ function abstract_eval_statement_expr(interp::AbstractInterpreter, e::Expr, vtyp
elseif ehead === :gc_preserve_end || ehead === :leave || ehead === :pop_exception ||
ehead === :global || ehead === :popaliasscope
return RTEffects(Nothing, Union{}, Effects(EFFECTS_TOTAL; effect_free=EFFECT_FREE_GLOBALLY))
elseif ehead === :globaldecl
return RTEffects(Nothing, Any, EFFECTS_UNKNOWN)
elseif ehead === :thunk
return RTEffects(Any, Any, EFFECTS_UNKNOWN)
end
Expand Down
1 change: 1 addition & 0 deletions base/compiler/validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const VALID_EXPR_HEADS = IdDict{Symbol,UnitRange{Int}}(
:copyast => 1:1,
:meta => 0:typemax(Int),
:global => 1:1,
:globaldecl => 2:2,
:foreigncall => 5:typemax(Int), # name, RT, AT, nreq, (cconv, effects), args..., roots...
:cfunction => 5:5,
:isdefined => 1:2,
Expand Down
5 changes: 5 additions & 0 deletions stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2391,3 +2391,8 @@ let (c, r, res) = test_complete_context("const xxx = Base.si", Main)
@test res
@test "sin" c
end

let (c, r, res) = test_complete_context("global xxx::Number = Base.", Main)
@test res
@test "pi" c
end

0 comments on commit 1c7ce01

Please sign in to comment.