briancavalier / creed

Sophisticated and functionally-minded async with advanced features: coroutines, promises, ES2015 iterables, fantasy-land
https://briancavalier.github.io/creed
MIT License
273 stars 20 forks source link

TypeError: Cannot read property 'near' of undefined #106

Closed Akkuma closed 7 years ago

Akkuma commented 7 years ago

In v1.1.0 I'm seeing this error, but I don't see this error in v1.0.4 or v1.0.2. The specific area I'm seeing this is when using a coroutine, so creed.coroutine(generator)(val).then(x => x) is enough to trigger it for me.

briancavalier commented 7 years ago

Thanks @Akkuma, I'll look into it.

briancavalier commented 7 years ago

It seems rollup or buble, not sure which, is incorrectly compiling the source. Here is the line that is blowing up. If you look at the line just before it and the line just after it, you can see the problem. The function expression on the line before it gets named to then$$1 by rollup/buble (I can tell it's rollup/buble since the there is no function expression in the original source). Then on the following line, rollup/buble incorrectly transforms the call to then, which is a function imported here, to then$$1, which causes the now-in-scope function expression named then$$1 to be called instead of the imported function. Since then$$1 is called as a function, it's this will be undefined, causing the error you are seeing.

Rollup and buble have been very reliable, so this is quite surprising. Unfortunately, though, this means the entire 1.1.0 build is broken.

Pinging @Rich-Harris to see if he has any advice--perhaps I'm doing something I shouldn't be. Otherwise, I may have to carefully rename all the functions whose names overlap with method names.

briancavalier commented 7 years ago

@Akkuma See #107 for a workaround that I'm planning to release as 1.1.1. If you have a chance, I'd love to know if that branch works for you. I used your example to test it (thanks for the example!), and it worked for me, so I'm hopeful.

briancavalier commented 7 years ago

I just released 1.1.1, which is exactly 1.1.0 built with the known-working rollup+buble configuration from 1.0.4. It should fix the issue, but please reopen if you still encounter a problem. Thank again for reporting this!