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

Bug with recursive partials #53

Closed
nicoulaj opened this issue Oct 7, 2012 · 6 comments
Closed

Bug with recursive partials #53

nicoulaj opened this issue Oct 7, 2012 · 6 comments
Milestone

Comments

@nicoulaj
Copy link
Contributor

nicoulaj commented Oct 7, 2012

When trying to use a recursive partial (ie partial that has itself as a partial), for instance example.mustache:

{{#someCondition}}
    {{>example}}
{{/someCondition}}

Mustache fails with a StackOverflowError in DefaultCode.clone():

java.lang.StackOverflowError
    at com.github.mustachejava.codes.DefaultCode.clone(DefaultCode.java:26)
    at com.github.mustachejava.codes.DefaultCode.clone(DefaultCode.java:30)
    at com.github.mustachejava.codes.DefaultCode.clone(DefaultCode.java:30)
    at com.github.mustachejava.codes.DefaultCode.clone(DefaultCode.java:30)
    ...
@nicoulaj
Copy link
Contributor Author

nicoulaj commented Oct 7, 2012

Related: mustache/mustache#29

@spullara
Copy link
Owner

spullara commented Oct 7, 2012

Interesting. There is supposedly a test for this in the spec. Thanks for the report.

@spullara
Copy link
Owner

spullara commented Oct 7, 2012

I just added something like this as a test and it passes (commit ebf8cbe). Can you send me a pull request with one that doesn't work? If someCondition is always true in your test (or at least a very large number of recursions), it will result in a stack overflow. If it isn't, it should work.

@nicoulaj
Copy link
Contributor Author

nicoulaj commented Oct 8, 2012

It was indeed trickier than simple recursion.

The template I compile actually extends the one that does recursion. I submitted a test case that shows the StackOverflowError.

Sorry for the incomplete report!

spullara added a commit that referenced this issue Oct 10, 2012
@spullara
Copy link
Owner

spullara commented Nov 5, 2012

I believe that I have heavy-handidly fixed this issue with this commit:

6d49aca

Your test now passes and the other tests still pass.

@spullara spullara closed this as completed Nov 5, 2012
@nicoulaj
Copy link
Contributor Author

nicoulaj commented Nov 6, 2012

I confirm the fix works on my real-world use case with nested partials and recursion.

Thanks for looking into this !

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