Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logical operator breaks dev and build #723

Open
1 task
marcosmartini opened this issue Feb 6, 2023 · 4 comments
Open
1 task

Logical operator breaks dev and build #723

marcosmartini opened this issue Feb 6, 2023 · 4 comments
Assignees
Labels
- P4: important Violate documented behavior or significantly improves performance (priority)

Comments

@marcosmartini
Copy link

What version of astro are you using?

2.0.6

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Mac

Describe the Bug

When using a logical operator (<=), Astro breaks and thinks there is something wrong with a fragment.

Code example:

<Layout title="Welcome to Astro.">
	<main>
		{
			[1,2,3,4,5,6,7,8,9].filter((_, index) => index <= 6 ).map(n => (
				<div>{n}</div>
			))
		}
	</main>
</Layout>

The following breaks it: index <= 6

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-v8kbtt?file=src/pages/index.astro

Participation

  • I am willing to submit a pull request for this issue.
@cijiugechu
Copy link

I found that by removing all the spaces between the StartExpression( { ) and the TextToken it compiles successfully.

<Layout title="Welcome to Astro.">
	<main>
		{[1,2,3,4,5,6,7,8,9].filter((_, index) => index <= 6 ).map(n => (
				<div>{n}</div>
			))
		}
	</main>
</Layout>

Strange bug, probably caused by the tokenizer in the compiler.

@marcosmartini
Copy link
Author

Thanks, @cijiugechu, that works!

@Princesseuh
Copy link
Member

Moving to the compiler repo, thank you for investigating!

@Princesseuh Princesseuh transferred this issue from withastro/astro Feb 8, 2023
@natemoo-re natemoo-re added the - P4: important Violate documented behavior or significantly improves performance (priority) label Jun 27, 2023
@mpstaton
Copy link

This fix doesn't work for me.

@MoustaphaDev MoustaphaDev marked this as a duplicate of #894 Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly improves performance (priority)
Projects
None yet
Development

No branches or pull requests

5 participants