Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property id of VariableDeclarator expected node to be of a type ["LVal"] but instead got null #402

Closed
bmathews opened this issue Feb 2, 2017 · 3 comments
Labels
bug Confirmed bug

Comments

@bmathews
Copy link

bmathews commented Feb 2, 2017

This code is causing this error:

Property id of VariableDeclarator expected node to be of a type ["LVal"] but instead got null
function test() {
  if (false) {
    for (var i = 0; i < 3; i++) {
      var something = 5;
    }
  }
}

test();

Here's a link to the repl demonstrating it:

http://babeljs.io/repl/#?babili=true&evaluate=false&lineWrap=false&presets=&targets=&browsers=&builtIns=false&code=function%20test()%20%7B%0A%20%20if%20(false)%20%7B%0A%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%203%3B%20i%2B%2B)%20%7B%0A%20%20%20%20%20%20var%20something%20%3D%205%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A%0Atest()%3B&experimental=false&loose=false&spec=false&playground=true

Stack trace:

TypeError: unknown: Property id of VariableDeclarator expected node to be of a type ["LVal"] but instead got null
    at Object.validate (/usr/local/lib/node_modules/babili/node_modules/babel-types/lib/definitions/index.js:109:13)
    at validate (/usr/local/lib/node_modules/babili/node_modules/babel-types/lib/index.js:509:9)
    at Object.builder (/usr/local/lib/node_modules/babili/node_modules/babel-types/lib/index.js:470:7)
    at VariableDeclaration (/usr/local/lib/node_modules/babili/node_modules/babel-plugin-minify-dead-code-elimination/lib/index.js:935:34)
    at NodePath._call (/usr/local/lib/node_modules/babili/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/usr/local/lib/node_modules/babili/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/usr/local/lib/node_modules/babili/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (/usr/local/lib/node_modules/babili/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitSingle (/usr/local/lib/node_modules/babili/node_modules/babel-traverse/lib/context.js:108:19)
    at TraversalContext.visit (/usr/local/lib/node_modules/babili/node_modules/babel-traverse/lib/context.js:192:19)

Edit: Updated with less code to reproduce and added stack trace

@boopathi boopathi added the bug Confirmed bug label Feb 2, 2017
vigneshshanmugam added a commit to vigneshshanmugam/babili that referenced this issue Feb 2, 2017
vigneshshanmugam added a commit to vigneshshanmugam/babili that referenced this issue Feb 2, 2017
@bmathews
Copy link
Author

bmathews commented Feb 2, 2017

🙇 thanks!

@niksajanjic
Copy link

I'm getting the same error:
Property id of VariableDeclarator expected node to be of a type ["LVal"] but instead got null

On the latest version of babel-core@6.26.0 with the following code (this is not the actual code, but it's numbed down to pinpoint the issue):

const configureStore = env => {
  return {
    store: 'store',
    persistor: 'persistor'
  }
}

export const { store, persistor } = configureStore(process.env.NODE_ENV)

But if I just change the code slightly by moving process.env.NODE_ENV to a function parameter and making it default value, it will compile:

const configureStore = (env = process.env.NODE_ENV) => {
  return {
    store: 'store',
    persistor: 'persistor'
  }
}

export const { store, persistor } = configureStore()

If needed, I can paste the actual code. This is strange, but I'm not sure if it's valuable to open a new issue for that. Any thoughts? Does it make sense to open a separate issue for this?

@jakesylvestre
Copy link

@niksajanjic I think so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

4 participants