Skip to content

Await Parenthesis #4267

@j3rem1e

Description

@j3rem1e

Describe the bug

If a component contains a javascript statement "await (expression)", then svelte removes the parenthesis in the generated javascript. However, the execution order is not the same (at least in chrome) :

"await a || b" is executed as "(await a) || b"

The bug is probably a regression between 3.12 and 3.17.1

To Reproduce

https://svelte.dev/repl/79a4dad98f3f41d7ae9840d3eb8209ea?version=3.17.1

	async function myTest() {
		let a, b;
		let c = await (a || b);
	}

has been outputed as

async function myTest() {
	let a, b;
	let c = await a || b;
}

Expected behavior

The parenthesis should not be removed in the generated javascript.

Information about your Svelte project:

  • Chrome 77
  • Svelte 3.17.1
  • Windows 7
  • Webpack

Severity

This is a minor issue because a workaround is easy to write, however the generated javascript is not correct and it's a regression with a previous version of svelte. it was not easy to find the cause of this new bugs in my application.

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