Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

🐛 Crash at @ character in class name / body #4669

@MahnurA

Description

@MahnurA

Environment information

Cannot run rome rage, issue found by fuzzer.

**Additional Context**: 
Discovered by: Implement round-trip fuzzers for finding correctness bugs [#4559](https://github.com/rome/tools/pull/4559)

What happened?

The following cases crash with the thread '<unnamed>' panicked at 'assertion failed: modifiers.is_empty()', /rome/tools/crates/rome_js_parser/src/syntax/class.rs:567:13:

class C {
	@decorator
	}
 class C { 
	@
	}
  1. class @
  2. class C@

I suspect there are actually two bugs here:

  1. That the class name is not flagged as invalid if there is an invalid class name containing the @ sign
  2. If encounters an @ sign as the first character when calling a class member - crashes. Calling a decorator on nothing within a class results in an unhandled crash, i.e. not categorized as an invalid decorated class member.

Affected formatters:
rome_format_d_ts
rome_format_jsx
rome_format_module
rome_format_script
rome_format_tsx
rome_format_typescript

Expected result

Formatters should not crash.

Code of Conduct

  • I agree to follow Rome's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-To triageStatus: user report of a possible bug that needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions