weepy / kaffeine

Extended Javascript for Pros
http://weepy.github.com/kaffeine/
MIT License
180 stars 16 forks source link

Kaffeine chokes on some return statements #22

Open felixge opened 13 years ago

felixge commented 13 years ago

Kaffeine chockes on return statements like this:

return typeof step === 'string';

The output I get is:

/var/git/transloader.transload.it/api2/node_modules/transloadit/assembly.js (compiled):254
      return typeof return step === 'string';
                    ^^^^^^

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
SyntaxError: Unexpected token return
    at Module._compile (module.js:399:25)
    at /usr/local/lib/node_modules/kaffeine/lib/index.js:94:12
    at Object..js (/var/git/transloader.transload.it/api2/node_modules/transloadit/transloadit.js:9:12)
    at Module.load (module.js:336:31)
    at Function._load (module.js:297:12)
    at require (module.js:348:19)
    at Object.<anonymous> (/var/git/transloader.transload.it/api2/node_modules/transloadit/assembly_manager.js (compiled):4:16)
    at Module._compile (module.js:404:26)
    at /usr/local/lib/node_modules/kaffeine/lib/index.js:94:12
    at Object..js (/var/git/transloader.transload.it/api2/node_modules/transloadit/transloadit.js:9:12)

The problem goes way when changing my line to:

return (typeof step === 'string');

But since my code was valid JS to begin with, I think this is probably a bug.

weepy commented 13 years ago

Yep that's a bug. Easy to fix luckily

Tapped on my fone

On 16 Apr 2011, at 18:09, felixge reply@reply.github.com wrote:

Kaffeine chockes on return statements like this:

return typeof step === 'string';

The output I get is:

/var/git/transloader.transload.it/api2/node_modules/transloadit/assembly.js (compiled):254 return typeof return step === 'string'; ^^^^^^

node.js:134 throw e; // process.nextTick error, or 'error' event on first tick ^ SyntaxError: Unexpected token return at Module._compile (module.js:399:25) at /usr/local/lib/node_modules/kaffeine/lib/index.js:94:12 at Object..js (/var/git/transloader.transload.it/api2/node_modules/transloadit/transloadit.js:9:12) at Module.load (module.js:336:31) at Function._load (module.js:297:12) at require (module.js:348:19) at Object. (/var/git/transloader.transload.it/api2/node_modules/transloadit/assembly_manager.js (compiled):4:16) at Module._compile (module.js:404:26) at /usr/local/lib/node_modules/kaffeine/lib/index.js:94:12 at Object..js (/var/git/transloader.transload.it/api2/node_modules/transloadit/transloadit.js:9:12)

The problem goes way when changing my line to:

return (typeof step === 'string');

But since my code was valid JS to begin with, I think this is probably a bug.

Reply to this email directly or view it on GitHub: https://github.com/weepy/kaffeine/issues/22

weepy commented 13 years ago

please let me know with any other return statements that don't work as expected ...

weepy commented 13 years ago

I think what I need to do here is create the concept of operators such as

unary

binary

weepy commented 13 years ago

for the moment I've pushed an easy fix for this - you suggested there was some other cases where it choked?

felixge commented 13 years ago

I have the same problem with instanceof. For example:

return file instanceof StreamFile

Produces the same issues.

weepy commented 13 years ago

I've pushed a fix for this - also fixes the problem with the regexs