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

{} in an attribute list causes the compiler/linter to crash instead of producing a meaningful error #6086

Closed
CherryDT opened this issue Mar 14, 2021 · 5 comments

Comments

@CherryDT
Copy link

CherryDT commented Mar 14, 2021

Describe the bug
{} in an attribute list causes the compiler/linter to crash instead of producing a meaningful error.

To Reproduce

<span {}></span>

https://svelte.dev/repl/e8b23903c76b4e9daf28185841799a87?version=3.35.0

The result is an exception TypeError: Cannot read property 'length' of null which doesn't really indicate what happened and where (in VSCode this shows at (1, 1)).

Expected behavior
A meaningful error like Variable name or spread operator expected.

Stacktraces

Stack trace

bundler.js:11 TypeError: Cannot read property 'length' of null
at read_attribute (compiler.js:16002)
at tag (compiler.js:15862)
at new Parser$1 (compiler.js:16787)
at parse$3 (compiler.js:16919)
at Object.compile (compiler.js:29918)
at Object.transform (bundler.js:11)
at bundler.js:11

  • Svelte version: 3.35.0
@dummdidumm
Copy link
Member

If this would parse and return as an entry in the list of warnings afterwards it would also help #4818

@Conduitry
Copy link
Member

@dummdidumm What would you want it to parse as? The same as if it weren't there at all?

@dummdidumm
Copy link
Member

Honestly I don't care, I just don't want it to abort parsing, which would improve editor intellisense 😄 treating it as if it weren't there at all makes the most sense to me.

dummdidumm pushed a commit that referenced this issue Jun 22, 2021
…orthand attribute (#6217)

Added error message "empty-attribute-shorthand" for when the shorthand attribute is empty,
giving a more explicit error for #6086
@dummdidumm
Copy link
Member

#6217 was merged, giving a more meaningful error for this situation. I'm not sure if we should close this now or keep it upon until we decide if this should be a warning in the future, or only do that in a more loose AST parsing mode, which would need to be implemented and which would help for #4818

@tanhauhau
Copy link
Member

yes i think we can close this issue for now, given that we have a meaningful error now.

for improving editor intellisense developer experience, we can explore that in #4818

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

No branches or pull requests

4 participants