Skip to content

Precedence issue when comparing numbers in component HTML code #3564

Closed
@antony

Description

@antony

Describe the bug
Trying to compare two numbers inline in HTML code blocks causes incorrect code to be generated, resulting in incorrect results.

{1 === 1} shows as false.

To Reproduce
https://svelte.dev/repl/60c43a6dd4ec4d7a8d1337342a48695b?version=3.12.1

Or try {1 === 1} in your code.

Expected behavior
(1 === 1) === true

Output is:

t0_value = 1 === 1 + ""

and should be something like:

t0_value = (1 === 1) + ""

Information about your Svelte project:

  • Svelte 3.12.1

Severity
This doesn't block, but is severe, since any such comparisons made will be wrong, and this could break a number of pre-existing components.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions