Skip to content

Commit 1c7ce01

Browse files
authored
inference: add basic support for :globaldecl expressions (#55144)
Following up #54773. Required for external abstract interpreters that may run inference on arbitrary top-level thunks.
1 parent 946301c commit 1c7ce01

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,6 +2705,8 @@ function abstract_eval_statement_expr(interp::AbstractInterpreter, e::Expr, vtyp
27052705
elseif ehead === :gc_preserve_end || ehead === :leave || ehead === :pop_exception ||
27062706
ehead === :global || ehead === :popaliasscope
27072707
return RTEffects(Nothing, Union{}, Effects(EFFECTS_TOTAL; effect_free=EFFECT_FREE_GLOBALLY))
2708+
elseif ehead === :globaldecl
2709+
return RTEffects(Nothing, Any, EFFECTS_UNKNOWN)
27082710
elseif ehead === :thunk
27092711
return RTEffects(Any, Any, EFFECTS_UNKNOWN)
27102712
end

base/compiler/validation.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const VALID_EXPR_HEADS = IdDict{Symbol,UnitRange{Int}}(
2222
:copyast => 1:1,
2323
:meta => 0:typemax(Int),
2424
:global => 1:1,
25+
:globaldecl => 2:2,
2526
:foreigncall => 5:typemax(Int), # name, RT, AT, nreq, (cconv, effects), args..., roots...
2627
:cfunction => 5:5,
2728
:isdefined => 1:2,

stdlib/REPL/test/replcompletions.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,3 +2391,8 @@ let (c, r, res) = test_complete_context("const xxx = Base.si", Main)
23912391
@test res
23922392
@test "sin" c
23932393
end
2394+
2395+
let (c, r, res) = test_complete_context("global xxx::Number = Base.", Main)
2396+
@test res
2397+
@test "pi" c
2398+
end

0 commit comments

Comments
 (0)