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

Serialize maps/lists when reconstructing lazily in case element(s) are updated #987

Open
jasmith-hs opened this issue Jan 12, 2023 · 1 comment

Comments

@jasmith-hs
Copy link
Contributor

{% set list = [] %}
{% set map = {} %}
{% do list.append(map) %}
{% if deferred %}
{% do list.append(1) %}
{% endif %}
{% do map.update({'a': 'A'}) %}
{{ list }}

This currently becomes:

{% set list = [{} ] %}{% if deferred %}
{% do list.append(1) %}
{% endif %}

{{ list }}

When it should be more like:

{% set list = [{'a': 'A'} ] %}{% if deferred %}
{% do list.append(1) %}
{% endif %}

{{ list }}

Or at least create a deferred node so that we know that something went wrong. The best way I can currently think of to solve this is to make the serialization which is part of the set-tag reconstruction lazy.
This would require a great deal of refactoring so I don't know if it is worth it to solve.

@jasmith-hs
Copy link
Contributor Author

Here's another example:

{% set references = [] %}
{% macro appender(refArray) %}
{% for i in range(1) %}
{% if deferred %}
{% do refArray.append(1) %}
{% endif %}
{% endfor %}
{{ caller() }}
{% endmacro %}
{% call appender(references) %}
{% set ref = references[0] %}
{{ ref }}
{% endcall %}
{{ references }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant