<div dir="ltr">2008/10/8 Robert Virding <span dir="ltr"><<a href="mailto:rvirding@gmail.com">rvirding@gmail.com</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">I am running R12B-4 and have generated code with Lisp Flavoured Erlang.<br><br>There is a bug in eval_element/3 which is called from fold_call/4 which tries to safely evaluate calls at compile time. Eval_element tries to evaluate calls to element/2. It also tries to check if the call is guaranteed to fail in which case it replaces the original call with a call to erlang:error(badarg). It is this check which is causing the bug as it is so tuned to code generated by the vanilla erlang compiler that it does not accept a nested call in the element. This is the bug.<br>

<br>I would also argue that such a substitution has very little noticeable effect as any evaluation of the arguments to element/2 have been broken out and will already be evaluated before the code ever reaches the erlang:error call. It, in fact, saves very little.<br>

</div></blockquote><div><br>The optimization in itself may not be worthwhile (because the code being optimized is probably wrong), but there will also be a warning about a call to element/2 that will always fail. The warning could be useful.<br>
<br>I have updated eval_element/2 to be more careful.<br><br></div></div><br>-- <br>Björn Gustavsson, Erlang/OTP, Ericsson AB<br>
</div>