Skip to content

Cannot set property 'trailingComments' of null when parsing destructuring array assignment with two trailing comments right next to each other #10488

@tschaei

Description

@tschaei

Bug Report

Current Behavior
Given a array parameter with two trailing comments right after each other parsing the code fails with the error Cannot set property 'trailingComments' of null.

Input Code
https://astexplorer.net/#/gist/a9695795c5bcf8dcba3fd886b025add0/46534ba4d7c94712ba4d45ee0de058c0213ee0cf

function foo([foo, /* not used */, /* not used */]) {
}

Expected behavior/code
Babel parses the code without throwing Cannot set property 'trailingComments' of null

Environment

  • Babel version(s): v7.6.0
  • Node/npm version: Node 10/npm 6
  • OS: Ubuntu 16.04
  • Monorepo: no
  • How you are using Babel: angular-cli

Additional context/Screenshots
Testing this locally I could reproduce the error using @babel/parser 7.6.2 and 7.6.0. Using @babel/parser 7.5.5 the above code parses just fine.
I suspect c0e3fa0#diff-0175b6ff28e6c7e30e7ecd5c13749187 might have introduced this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions