Skip to content

passing let let to the parser should throw an error  #8269

@sapphi-red

Description

@sapphi-red

Describe the bug

let is reserved in let/const/class declarations in non-strict mode, but SWC parser doesn't reject them.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#:~:text=(also%20reserved%20in%20const%2C%20let%2C%20and%20class%20declarations)

Input code

{
    let let
}
{
    const let = 0
}
{
    class let {}
}

Config

No response

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.3.97&code=H4sIAAAAAAAAA6vm5VIAgpzUEhDm5arl5aqGCCXn5xWDBRVsFQxQJHISi4vBEtW1YHEAdYxiO0QAAAA%3D&config=H4sIAAAAAAAAA1VPOw7DIAzdcwrkuUPF0CF36CEs6kRE%2FISpVBTl7iUB0mbz%2B%2FnZ6yAELKxgFGsZCwgYmeKJC8PZJfwUBkhZZBV1SHDr6sK7NKFhOqitKpAwzpSOFMu7lC0Bxnumnmic1U5P%2Bb9TeRsiMV%2BNuxXdbOjaOLRWsP71PsT2S8qB6gUP%2BJl62bkYND97sq7dvnp7734YAQAA

SWC Info output

No response

Expected behavior

Throws an error like Unexpected reserved word 'let'.

Actual behavior

No error happens.

Version

1.3.97

Additional context

This errors with most parsers on https://astexplorer.net/.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions