Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for allowing :throw_undef_if_not on the frontend #53944

Merged
merged 2 commits into from
Apr 4, 2024
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
2 changes: 1 addition & 1 deletion base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2637,7 +2637,7 @@ function abstract_eval_statement_expr(interp::AbstractInterpreter, e::Expr, vtyp
else
t = Union{}
end
elseif !hasintersect(windenconst(condt), Bool)
elseif !hasintersect(widenconst(condt), Bool)
t = Union{}
end
elseif ehead === :boundscheck
Expand Down
2 changes: 1 addition & 1 deletion src/method.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static jl_value_t *resolve_globals(jl_value_t *expr, jl_module_t *module, jl_sve
jl_exprargset(e, 0, resolve_globals(jl_exprarg(e, 0), module, sparam_vals, binding_effects, 1));
i++;
}
if (e->head == jl_method_sym || e->head == jl_module_sym) {
if (e->head == jl_method_sym || e->head == jl_module_sym || e->head == jl_throw_undef_if_not_sym) {
i++;
}
for (; i < nargs; i++) {
Expand Down
16 changes: 16 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5647,6 +5647,22 @@ end
@test Core.Compiler.return_type(has_tuin, Tuple{}) === Union{}
@test_throws UndefVarError has_tuin()

function gen_tuin_from_arg(world::UInt, source, _, _)
ci = make_codeinfo(Any[
Expr(:throw_undef_if_not, :x, Core.Argument(2)),
ReturnNode(true),
]; slottypes=Any[Any, Bool])
ci.slotnames = Symbol[:var"#self#", :def]
ci
end

@eval function has_tuin2(def)
$(Expr(:meta, :generated, gen_tuin_from_arg))
$(Expr(:meta, :generated_only))
end
@test_throws UndefVarError has_tuin2(false)
@test has_tuin2(true)

# issue #53585
let t = ntuple(i -> i % 8 == 1 ? Int64 : Float64, 4000)
@test only(Base.return_types(Base.promote_typeof, t)) == Type{Float64}
Expand Down