Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:25
erlang
1622-Infer-types-based-on-BIF-calls.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1622-Infer-types-based-on-BIF-calls.patch of Package erlang
From 26af49561c9ce9f511a5143fd448afceb892fc7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Sun, 27 Nov 2022 12:06:12 +0100 Subject: [PATCH 2/4] Infer types based on BIF calls We infer types based on guard BIFs, but not other BIFs. This seems to be an oversight. --- lib/compiler/src/beam_ssa_type.erl | 9 +++++++++ lib/compiler/src/beam_validator.erl | 10 ++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/compiler/src/beam_ssa_type.erl b/lib/compiler/src/beam_ssa_type.erl index 67f3cb76c9..52928e7b65 100644 --- a/lib/compiler/src/beam_ssa_type.erl +++ b/lib/compiler/src/beam_ssa_type.erl @@ -2708,6 +2708,15 @@ infer_success_type({bif,Op}, Args, Ts, _Ds) -> infer_success_type(call, [#b_var{}=Fun|Args], _Ts, _Ds) -> T = {Fun, #t_fun{arity=length(Args)}}, {[T], []}; +infer_success_type(call, [#b_remote{mod=#b_literal{val=Mod}, + name=#b_literal{val=Name}}|Args], + Ts, _Ds) -> + ArgTypes = concrete_types(Args, Ts), + + {_, PosTypes0, _CanSubtract} = beam_call_types:types(Mod, Name, ArgTypes), + PosTypes = [T || {#b_var{},_}=T <- zip(Args, PosTypes0)], + + {PosTypes, []}; infer_success_type(bs_start_match, [_, #b_var{}=Src], _Ts, _Ds) -> T = {Src,#t_bs_matchable{}}, {[T], [T]}; diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl index 6d6b9af268..1558abfcd6 100644 --- a/lib/compiler/src/beam_validator.erl +++ b/lib/compiler/src/beam_validator.erl @@ -1352,10 +1352,16 @@ validate_body_call(Func, Live, verify_call_args(Func, Live, Vst), SuccFun = fun(SuccVst0) -> - {RetType, _, _} = call_types(Func, Live, SuccVst0), + {RetType, ArgTypes, _} = call_types(Func, Live, SuccVst0), true = RetType =/= none, %Assertion. - SuccVst = schedule_out(0, SuccVst0), + Args = [{x,X} || X <- lists:seq(0, Live-1)], + ZippedArgs = zip(Args, ArgTypes), + SuccVst1 = foldl(fun({A, T}, V) -> + update_type(fun meet/2, T, A, V) + end, SuccVst0, ZippedArgs), + + SuccVst = schedule_out(0, SuccVst1), create_term(RetType, call, [], {x,0}, SuccVst) end, -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor