Skip to content

Instantly share code, notes, and snippets.

@jfacorro
Last active March 18, 2017 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfacorro/1749fb8f3cee1f55a1bd8da3ec84cb31 to your computer and use it in GitHub Desktop.
Save jfacorro/1749fb8f3cee1f55a1bd8da3ec84cb31 to your computer and use it in GitHub Desktop.
sys_core_fold generates invalid Core Erlang
Module =
{c_module,[],
{c_literal,[],cerl_eval0},
[{c_var,[],{eval,0}},
{c_var,[],{module_info,0}},
{c_var,[],{module_info,1}}],
[{{c_literal,[],clojure},{c_literal,[],true}}],
[{{c_var,[],{eval,0}},
{c_fun,[],[],
{c_case,[1,{file,[]}],
{c_literal,[1,{file,[]}],[1,2,3,4]},
[{c_clause,[1,{file,[]}],
[{c_literal,[1,{file,[]}],[1,2,3]}],
{c_literal,[],true},
{c_literal,[1,{file,[]}],undefined}}]}}},
{{c_var,[],{module_info,0}},
{c_fun,[],[],
{c_call,[],
{c_literal,[],erlang},
{c_literal,[],get_module_info},
[{c_literal,[],cerl_eval0}]}}},
{{c_var,[],{module_info,1}},
{c_fun,[],
[{c_var,[],x}],
{c_call,[],
{c_literal,[],erlang},
{c_literal,[],get_module_info},
[{c_literal,[],cerl_eval0},{c_var,[],x}]}}}]}.
%% This call results in an error
compile:noenv_forms(Module, [clint, from_core, return_errors]).
%% This returns the Core Erlang code generated after the constast folding optimization for Core (sys_core_fold).
compile:noenv_forms(Module, [clint, from_core, return_errors, dcorefold]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment