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:
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.
This was broken by #3394. There are a few places in the code where we're looking at the precedence of the top-level operator in an expression and deciding whether we need to wrap it in parentheses, but simplest would be to just always wrap it.
I don't know whether this would be affected or fixed by #3539.
Hi guys!, I reviewed this issue using "code-red" branch mentioned in #3539 and work fine!
Fixed by #3539, test added in #3722.