Skip to content

3.0 regression/inconsistency when comparing a float to a numeric string with trailing space #3345

Description

@guilliamxavier

This is a proper bug report for PR #3256.

Code sample:

{{ 42 == '42' ? '.' : 'F' -}}
{{ '42' == 42 ? '.' : 'F' -}}
{{ 42 == ' 42' ? '.' : 'F' -}}
{{ ' 42' == 42 ? '.' : 'F' -}}
{{ 42 == '42 ' ? '.' : 'F' -}}
{{ '42 ' == 42 ? '.' : 'F' -}}
{{ 42.0 == '42.0' ? '.' : 'F' -}}
{{ '42.0' == 42.0 ? '.' : 'F' -}}
{{ 42.0 == ' 42.0' ? '.' : 'F' -}}
{{ ' 42.0' == 42.0 ? '.' : 'F' -}}
{{ 42.0 == '42.0 ' ? '.' : 'F' -}}
{{ '42.0 ' == 42.0 ? '.' : 'F' -}}

Output in v1.42.0 and v2.12.5:
............

Output in v3.0.3:
..........FF

Note that only the "float with trailing space" tests fail (whereas the "float with leading space" tests pass, and all the "int" tests pass).

Mini test harness: https://twigfiddle.com/6angrk

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