Skip to content

Default parameters aren't tracked properly #364

@Naddiseo

Description

@Naddiseo

I was looking through the parser and noticed that default arguments for macro/call parameters aren't attached to the parameter they were defined with. This can lead to unexpected behaviour:

>>> import jinja2
>>> jinja2.Template("{% macro a(b, c=1, d) %}b={{b}},c={{c}},d={{d}}{% endmacro %} {{ a() }}").render()
u' b=,c=,d=1'

Here you can see that the default was applied to parameter d instead of c. There are two fixes for this:

  • Tie the defaults to the parameter they were defined from
  • Throw a synxtax error like python does: SyntaxError: non-default argument follows default argument

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions