Skip to content

[Bug]: Parser accepts illegal syntax obj.[prop] #13694

@overlookmotel

Description

@overlookmotel

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

val = obj.[prop];

REPL

Configuration file name

n/a

Configuration

n/a

Current and expected behavior

obj.[prop] is not legal Javascript (note the . before [). Would expect parser to throw an error.

Instead, it parses it as if it was obj[prop] (i.e. without the .).

Environment

System:
  OS: macOS Mojave 10.14.6
Binaries:
  Node: 16.7.0 - ~/.nvm/versions/node/v16.7.0/bin/node
  npm: 7.20.3 - ~/.nvm/versions/node/v16.7.0/bin/npm
npmPackages:
  @babel/core: ^7.15.0 => 7.15.0 
  @babel/generator: ^7.15.0 => 7.15.0 
  @babel/helper-module-transforms: ^7.15.0 => 7.15.0 
  @babel/helper-plugin-utils: ^7.14.5 => 7.14.5 
  @babel/parser: ^7.15.3 => 7.15.3 
  @babel/plugin-transform-arrow-functions: ^7.14.5 => 7.14.5 
  @babel/plugin-transform-modules-commonjs: ^7.15.0 => 7.15.0 
  @babel/plugin-transform-react-jsx: ^7.14.9 => 7.14.9 
  @babel/plugin-transform-strict-mode: ^7.14.5 => 7.14.5 
  @babel/register: ^7.15.3 => 7.15.3 
  @babel/traverse: ^7.15.0 => 7.15.0 
  @babel/types: ^7.15.0 => 7.15.0 
  babel-jest: ^27.0.6 => 27.0.6 
  babel-plugin-dynamic-import-node: ^2.3.3 => 2.3.3 
  eslint: ^7.32.0 => 7.32.0 
  jest: ^27.0.6 => 27.0.6

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

i: regressionoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions