Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:19
erlang
0188-sys_core_fold-Fix-unsafe-optimization-of-n...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0188-sys_core_fold-Fix-unsafe-optimization-of-non-variabl.patch of Package erlang
From f59e70ce61913356a67d58e03d6b68c29e983363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Mon, 7 Aug 2017 07:00:14 +0200 Subject: [PATCH] sys_core_fold: Fix unsafe optimization of non-variable apply The sys_core_fold pass would do an unsafe "optimization" when an apply operation did not have a variable in the function position as in the following example: > cat test1.core module 'test1' ['test1'/2] attributes [] 'i'/1 = fun (_f) -> _f 'test1'/2 = fun (_f, _x) -> apply apply 'i'/1 (_f) (_x) end > erlc test1.core no_file: Warning: invalid function call Reported-by: Mikael Pettersson --- lib/compiler/src/sys_core_fold.erl | 6 +- lib/compiler/test/core_SUITE.erl | 8 ++- .../test/core_SUITE_data/non_variable_apply.core | 80 ++++++++++++++++++++++ 3 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 lib/compiler/test/core_SUITE_data/non_variable_apply.core diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl index e0cd6da06..d73060fb7 100644 --- a/lib/compiler/src/sys_core_fold.erl +++ b/lib/compiler/src/sys_core_fold.erl @@ -395,10 +395,10 @@ expr(#c_receive{clauses=Cs0,timeout=T0,action=A0}=Recv, Ctxt, Sub) -> expr(#c_apply{anno=Anno,op=Op0,args=As0}=App, _, Sub) -> Op1 = expr(Op0, value, Sub), As1 = expr_list(As0, value, Sub), - case Op1 of - #c_var{} -> + case cerl:is_data(Op1) of + false -> App#c_apply{op=Op1,args=As1}; - _ -> + true -> add_warning(App, invalid_call), Err = #c_call{anno=Anno, module=#c_literal{val=erlang}, -- 2.14.0
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