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

{{1-1}} for simple math throws unexpected integer, expected end of variable block #93

Closed
joshuataylor opened this issue Sep 3, 2022 · 1 comment · Fixed by #94
Closed

Comments

@joshuataylor
Copy link
Sponsor Contributor

Description

Trying to do {{1-1}} throws the following error:

called `Result::unwrap()` on an `Err` value: Error { kind: SyntaxError, detail: Some("unexpected integer, expected end of variable block"), name: Some("ranges"), lineno: 1, source: None }

This is the smallest reproduction I can create, the main reason for this is for ranges:

{% for i in range(1, 5) %}
{{i-1}}
{% endfor %}

Reproduction steps

{{1-1}}


Additional helpful information:

## What did you expect
Working math :)
@joshuataylor
Copy link
Sponsor Contributor Author

It looks like this works:

{{1 - 1}}

This is because without a space, Minijinja parses it as a -1 (Negative 1).

Ok(
    Some(
        (
            INT(-1),
             @ 1:4-1:5,
        ),
    ),
)

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

Successfully merging a pull request may close this issue.

1 participant