Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Parsing error with polymorphic functions/generic type params #321

Closed
mynameistechno opened this issue Jun 12, 2016 · 14 comments
Closed

Parsing error with polymorphic functions/generic type params #321

mynameistechno opened this issue Jun 12, 2016 · 14 comments

Comments

@mynameistechno
Copy link

This used to work fine, but after a fresh install I've started getting this error. I haven't been able to narrow down exactly which module upgraded recently. This is potentially related to #266. I'm also unsure if the problem is with babel-eslint.

I'm using Babel, flow, and babel-eslint. Flow doesn't complain with the below, but eslint does:

// @flow
function setIfNotDefault<T>(obj: Object, key: string, val: T, def: T) {
  if (val !== def) {
    obj[key] = val;
  }
}
  0:0  error  Parsing error: Object.defineProperty called on non-object
@mynameistechno mynameistechno changed the title Parsing error with polymorphic functions Parsing error with polymorphic/generic functions Jun 12, 2016
@mynameistechno mynameistechno changed the title Parsing error with polymorphic/generic functions Parsing error with polymorphic/generics functions Jun 12, 2016
@mynameistechno mynameistechno changed the title Parsing error with polymorphic/generics functions Parsing error with polymorphic functions/generic type params Jun 12, 2016
@ghost
Copy link

ghost commented Jun 12, 2016

I've started running into this too and it definitely seems related to parsing of generic parameters. I don't think it's limited to functions either. It looks like it's also triggered by <…> in type declarations, at least in some cases.

@danez
Copy link
Member

danez commented Jun 12, 2016

If it really just started to happen recently, then it might be a regression in babylon. In the latest release of babylon there was one change related to flow.

@ghost
Copy link

ghost commented Jun 12, 2016

I think it must be some pretty recent update somewhere that is causing it because I only started noticing it in the last couple days after doing fresh installs. This is with packages that are only a few weeks old and didn't trigger the error originally.

I tried to install older versions of eslint and related packages but couldn't track down where the error first started showing up.

@hzoo
Copy link
Member

hzoo commented Jun 13, 2016

The recent change in babylon was babel/babylon#25

edit: which might of broke something

@mhagmajer
Copy link

mhagmajer commented Jun 13, 2016

Just like @hzoo said. I confirmed that locking the babylon dependency at 6.8.0 with npm-shrinkwrap solves the problem.

@rosskevin
Copy link

Confirmed for me, babylon@6.8.0 works, babylon@6.8.1 breaks.

@hzoo
Copy link
Member

hzoo commented Jun 13, 2016

Ok #322 - Need to change some logic in babel-eslint to account for the change in babylon and push a patch

The only place should be in #321

@matt-oakes
Copy link

Is there a simple workaround for this?

@hzoo
Copy link
Member

hzoo commented Jun 13, 2016

current workaround is pinning to 6.8.0 like mentioned above

@dotbear
Copy link

dotbear commented Jun 14, 2016

Thanks a lot @hzoo ! Been struggling with this for a while. 6.8.0 sorted me out :)

trotzig added a commit to Galooshi/import-js that referenced this issue Jun 14, 2016
I kept getting an error in Travis from eslint:

  import-js/lib/findJsModulesFor.js
  0:0  error  Parsing error: Object.defineProperty called on non-object

Initially, I wasn't getting this error locally. But after wiping
node_modules and reinstalling, I saw it there too. After some googling,
I came across this recent babel-eslint issue:

  babel/babel-eslint#321

In that thread, people suggest pinning babylon at 6.8.0 (a regression
was introduced in 6.8.1). We don't depend on that directly, but pinning
babel related dependencies to 6.8.0 seemed to do the trick.
trotzig added a commit to Galooshi/import-js that referenced this issue Jun 14, 2016
I kept getting an error in Travis from eslint:

  import-js/lib/findJsModulesFor.js
  0:0  error  Parsing error: Object.defineProperty called on non-object

Initially, I wasn't getting this error locally. But after wiping
node_modules and reinstalling, I saw it there too. After some googling,
I came across this recent babel-eslint issue:

  babel/babel-eslint#321

In that thread, people suggest pinning babylon at 6.8.0 (a regression
was introduced in 6.8.1). Doing that seems to do the trick.
trotzig added a commit to Galooshi/import-js that referenced this issue Jun 14, 2016
I kept getting an error in Travis from eslint:

  import-js/lib/findJsModulesFor.js
  0:0  error  Parsing error: Object.defineProperty called on non-object

Initially, I wasn't getting this error locally. But after wiping
node_modules and reinstalling, I saw it there too. After some googling,
I came across this recent babel-eslint issue:

  babel/babel-eslint#321

In that thread, people suggest pinning babylon at 6.8.0 (a regression
was introduced in 6.8.1). Doing that seems to do the trick.
kuychaco added a commit to atom/github that referenced this issue Jun 14, 2016
See discussion at babel/babel-eslint#321
We'll need to un-shrinkwrap in the future once the bug is fixed

Signed-off-by: Michelle Tilley <binarymuse@github.com>
as-cii pushed a commit to atom/github that referenced this issue Jun 15, 2016
See discussion at babel/babel-eslint#321
We'll need to un-shrinkwrap in the future once the bug is fixed

Signed-off-by: Michelle Tilley <binarymuse@github.com>
@dj-foxxy
Copy link

Hi, I'm getting this issue at the moment. I don't really know what I'm doing with npm. Can some tell me how to pin babylon? I tried just npm install babylon@6.8.0 but this didn't work.

@MoOx
Copy link

MoOx commented Jun 16, 2016

Just "npm rm babylon" and then "npm install babylon@6.8.0 --save[-dev] --save-exact". Did the trick for me.

jrdrg pushed a commit to jrdrg/dibslint that referenced this issue Jun 17, 2016
@hzoo
Copy link
Member

hzoo commented Jun 17, 2016

Ok thanks to @danez this should be fixed in babel 6.10.2 (babel-eslint uses babel-types, etc), so will need to npm install again

@hzoo hzoo closed this as completed Jun 17, 2016
@danez
Copy link
Member

danez commented Jun 17, 2016

The tests still fail. I think because the new TypeParameter is not visited/marked as seen.

https://travis-ci.org/babel/babel-eslint/jobs/127207221

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants