Skip to content

Another "Cannot read property 'end' of null" error #615

@zamb3zi

Description

@zamb3zi

Input

function foo(arg) {
    const { y } = arg, { z, x = null } = y;
    return z ? z : null;
}

Output

TypeError: test3.js: Cannot read property 'end' of null
    at _evaluate (C:\Users\John\Documents\GitHub\babili\packages\babili\node_modules\babel-traverse\lib\path\evaluation.js:159:57)
    at evaluate (C:\Users\John\Documents\GitHub\babili\packages\babili\node_modules\babel-traverse\lib\path\evaluation.js:65:17)
    ...

REPL

The following version does not produce an exception but generates incorrect output:

Input

function foo(arg) {
    const { y } = arg, { z, x = null } = y;
    return z;
}

Output

function foo(a){const{y:b}=a;return z}

REPL

Note: removing , x = null produces correct output. Alternatively returning x + z produces correct output (REPL)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions