Skip to content

[v4] Rollup panics when a code includes “__ or ”__ #5174

@sapphi-red

Description

@sapphi-red

Rollup Version

4.0.0

Operating System (or Browser)

REPL, Windows, WSL

Node Version (if applicable)

No response

Link To Reproduction

https://rollupjs.org/repl/?version=4.0.0&shareable=JTdCJTIyZXhhbXBsZSUyMiUzQW51bGwlMkMlMjJtb2R1bGVzJTIyJTNBJTVCJTdCJTIyY29kZSUyMiUzQSUyMiUyRiUyRiUyMCVFMiU4MCU5Q19fJTIyJTJDJTIyaXNFbnRyeSUyMiUzQXRydWUlMkMlMjJuYW1lJTIyJTNBJTIybWFpbi5qcyUyMiU3RCU1RCUyQyUyMm9wdGlvbnMlMjIlM0ElN0IlMjJvdXRwdXQlMjIlM0ElN0IlMjJmb3JtYXQlMjIlM0ElMjJlcyUyMiU3RCU3RCU3RA==

https://rollupjs.org/repl/?version=4.0.0&shareable=JTdCJTIyZXhhbXBsZSUyMiUzQW51bGwlMkMlMjJtb2R1bGVzJTIyJTNBJTVCJTdCJTIyY29kZSUyMiUzQSUyMiUyRiUyRiUyMCVFMiU4MCU5RF9fJTIyJTJDJTIyaXNFbnRyeSUyMiUzQXRydWUlMkMlMjJuYW1lJTIyJTNBJTIybWFpbi5qcyUyMiU3RCU1RCUyQyUyMm9wdGlvbnMlMjIlM0ElN0IlN0QlN0Q=

Expected Behaviour

No error happens.

Actual Behaviour

On REPL, the following error happens.

rror: RollupError: unreachable
    at Je (logs.ts:37:24)
    at ea.error (Module.ts:389:10)
    at ea.tryParse (Module.ts:1334:16)
    at ea.setSource (Module.ts:834:33)
    at Kl.addModuleSource (ModuleLoader.ts:317:11)

{cause: {}, code: 'PARSE_ERROR', id: '/main.js'}

On Windows/WSL, the following error happens

thread '<unnamed>' panicked at parse_ast\src\convert_ast\annotations.rs:24:26:
byte index 3 is not a char boundary; it is inside '“' (bytes 1..4) of ` “__`
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at parse_ast/src/convert_ast/annotations.rs:24:26:
byte index 3 is not a char boundary; it is inside '“' (bytes 1..4) of ` “__`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
Aborted

Real world code: https://github.com/d3/d3-brush/blob/ec2bce6f15074a9ead7f9a84c61335be51c123a3/src/brush.js#L125

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions