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

Haanga_Compiler_Exception if forloop.last is used in an array returned by an object method #25

Closed
josepanguera opened this issue Jan 19, 2014 · 0 comments
Assignees

Comments

@josepanguera
Copy link

With this object:

class Obj {
    public function method(){
        return array('a', 'b');
    }
}

and this template:

{% for a in obj.method %}
  {{ a }}

  {% if forloop.last %}
    test
  {% endif %}
{% endfor %}

an exception is thrown:

exception 'ErrorException' with message
'call_user_func_array() expects parameter 2 to be array, object given' in /.../vendor/crodas/haanga/lib/Haanga/AST.php:534

Stack trace:
#0 [internal function]: Slim\Slim::handleErrors(2, 'call_user_func_...', '/home/z/project...', 534, Array)
#1 /.../vendor/crodas/haanga/lib/Haanga/AST.php(534): call_user_func_array(Array, Object(Haanga_AST))
#2 /.../vendor/crodas/haanga/lib/Haanga/Compiler.php(1150): hvar_ex(Object(Haanga_AST))
#3 /.../vendor/crodas/haanga/lib/Haanga/Compiler.php(483): Haanga_Compiler->generate_op_loop(Array, Object(Haanga_AST))
#4 /.../vendor/crodas/haanga/lib/Haanga/Compiler.php(296): Haanga_Compiler->generate_op_code(Array, Object(Haanga_AST))
[...]

It does not happen with forloop.first.

@ghost ghost assigned crodas Jan 19, 2014
@crodas crodas closed this as completed in dd3c96a Jan 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants