Skip to content

🐛 BUG: Space in ending tag crashes the compiler #1007

Open
@Princesseuh

Description

What version of @astrojs/compiler are you using?

2.7.0

What package manager are you using?

pnpm

What operating system are you using?

macOS

Describe the Bug

In HTML, the following code:

<span>Hello</ span>

is invalid, but is corrected by the browser like this:

<span>Hello<!-- span-->
</span>

In the TSX output, writing the first snippet crashes the compiler.

panic: runtime error: index out of range [0] with length 0
goroutine 6 [running]:
github.com/withastro/compiler/internal/printer.renderTsx(0x14bb950, 0x14ad040)
	github.com/withastro/compiler/internal/printer/print-to-tsx.go:248 +0x1b6
github.com/withastro/compiler/internal/printer.renderTsx(0x14bb950, 0x14acdc0)
	github.com/withastro/compiler/internal/printer/print-to-tsx.go:523 +0x52f
github.com/withastro/compiler/internal/printer.renderTsx(0x14bb950, 0x14acb40)
	github.com/withastro/compiler/internal/printer/print-to-tsx.go:147 +0xba
github.com/withastro/compiler/internal/printer.PrintToTSX({0x14920a8, 0x12}, 0x14acb40, {{0x3c3c4, 0x6}, {0x14d20c0, 0x3e}, {0x14d20c0, 0x3e}, {0x46f38, ...}, ...}, ...)
	github.com/withastro/compiler/internal/printer/print-to-tsx.go:30 +0x12
main.main.ConvertToTSX.func3({{}, 0x7ff800010000000d, 0x140c6a0}, {0x1434140, 0x2, 0x2})
	./astro-wasm.go:263 +0xe
syscall/js.handleEvent()
	syscall/js/func.go:100 +0x23
exit code: 2

Link to Minimal Reproducible Example

https://live-astro-compiler.vercel.app/?editor-state=WzMxLDEzOSw4LDAsMTMwLDI0MSw4OSwxMDIsMiwzLDEwMSwxNDUsNzksNzUsMyw0OSwxNiwxOTcsMTkxLDEzOCwyMjgsOTIsODYsNDAsMTIwLDQxLDY5LDQwLDI0NSw0NywxMjAsMTQ0LDIyMSw4NSwxMjMsMjQwLDUwLDc3LDEwMiwzNyw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EsMTk4LDYxLDEwNSwxOTQsMTc0LDEsMCwwXQ%3D%3D

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    - P2: has workaroundBug, but has workaround (priority)feat: tsxRelated to the TSX output (scope)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions