CoffeeScriptRedux icon indicating copy to clipboard operation
CoffeeScriptRedux copied to clipboard

Fails to compile when subclass constructor calls super

Open olegam opened this issue 10 years ago • 22 comments

I can't compile this

class MyTestAbstract
  constructor: ->
    @created_at = new Date()

class MyTestConcrete extends MyTestAbstract
  constructor: ->
 .  super

Seems to be correct syntax but I get:

/usr/local/lib/node_modules/coffee-script-redux/bin/coffee --source-map -i test_class.coffee
Syntax error on line 7, column 9: unexpected '(DEDENT)' (\uEFFE)
4 : 
5 : class MyTestConcrete extends MyTestAbstract
6 :   constructor: ->
7 :     super
^ :~~~~~~~~^

See related question on SO: http://stackoverflow.com/questions/18914349/why-do-i-get-syntax-error-trying-to-call-super

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/1742549-fails-to-compile-when-subclass-constructor-calls-super?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github).

olegam avatar Sep 20 '13 10:09 olegam

super's not implemented yet, so yeah.

vendethiel avatar Sep 20 '13 10:09 vendethiel

Makes sense. Thanks for the great work you are doing. I got started using this based on the recommendation from this blogpost about getting coffee-script to work best with Jetbrains WebStorm: http://blog.jetbrains.com/webide/2013/03/coffeescript-debugging-with-sourcemaps-in-webstorm-6-phpstorm-6/

Is there a schedule for when you will implement features like this?

olegam avatar Sep 20 '13 12:09 olegam

Progress is here. Roadmap is here.

Also, you should be thanking @michaelficarra, not me (which also means I can't answer your last question). (and note that the original compiler now includes source maps)

vendethiel avatar Sep 20 '13 12:09 vendethiel

Got here through half a year old question on super in Redux, and after 6 months... :).

I absolutely understand that this project is now left with whatever time anyone willing to help have spare. But could someone explain to me what is the point of a half finished compiler while we have a working compiler? The roadmap now has no due dates. Wouldn't it be better to abandon this project and make sure people like @olegam don't get confused by articles which suggest using redux? Anytime I see "Fixed in redux" tag on the main repo, something moves inside of me. With all due respect to the contributors here...

xixixao avatar Oct 14 '13 23:10 xixixao

@xixixao: There are some issues with jashkenas/coffee-script that will be incredibly hard to fix because of the compiler's design. The remaining issues here will just take a bit of time to implement. super will probably take me 10-15 hours. Stepped loops can be done in under 4. There's only one issue (splices on LHS of assignment) that has exposed a design flaw in this compiler.

This project is just not as interesting for me right now as some of the other projects I'm working on. I have a lot of really cool stuff coming out soon. I use this compiler pretty much every day and fix bugs immediately as I come upon them. I don't know why many other people aren't motivated to contribute to OSS projects.

michaelficarra avatar Oct 15 '13 00:10 michaelficarra

super will probably take me 10-15 hours. Stepped loops can be done in under 4.

How soon are you going to fix it? These two problems are the only things that prevent me (and I suspect a huge number of people like me) from switching to CoffeeScript redux

antonkulaga avatar Dec 21 '13 11:12 antonkulaga

@antonkulaga: I recently negotiated 10% time to work on outstanding OSS issues for Groupon. I'll be prioritising work on CSR, especially these two issues, starting 2014.

michaelficarra avatar Dec 29 '13 23:12 michaelficarra

@michaelficarra Is there any way to run the CS test suite with Redux (I attempted this, but the internal API is different)? If not, would nice to enable that as well.

xixixao avatar Dec 30 '13 00:12 xixixao

There are some issues with jashkenas/coffee-script that will be incredibly hard to fix because of the compiler's design.

Not trolling but I've seen you mention this a number of times. Is there an up-to-date list of things that are possible in CSR that aren't possible (or are hard) to fix in jashkenas/coffee-script? The wiki page lists four and the open issues page lists 37, none of which are particularly compelling. What reason would I have to use CSR over CS these days?

akre54 avatar Dec 30 '13 00:12 akre54

https://github.com/jashkenas/coffee-script/issues/2342 This is the biggest issue. Other than that, the rewriter is an entangled mess imho.

vendethiel avatar Dec 30 '13 00:12 vendethiel

duplicate of issue #147

notslang avatar May 13 '14 09:05 notslang

Still no support of super?

davidbonnet avatar May 14 '14 13:05 davidbonnet

stumbled over this too .. a suggested workaround should at least be presented or documented shouldnt it ?

matthiasg avatar Sep 29 '14 06:09 matthiasg

This issue hasn't been addressed and the project seems to be abandonware. There is no real substitute for super, so the suggested workaround I went with was "don't use CoffeeScriptRedux". Hard to establish any practical use for it when it's not feature complete.

jordaaash avatar Sep 29 '14 06:09 jordaaash

there's a PR for this over here: https://github.com/michaelficarra/CoffeeScriptRedux/pull/313 ... not sure what's left to do on it

notslang avatar Oct 03 '14 22:10 notslang

try:

class Foo

  constructor: (@name) ->

class Bar extends Foo

  constructor: () ->
    Foo.apply this, ["Peter"]

tangzero avatar Oct 10 '14 00:10 tangzero

Only a substitute for super in the simplest case. Doesn't work with non-constructor methods.

jordaaash avatar Oct 10 '14 01:10 jordaaash

Really?

class Foo

  constructor: (@name) ->

  bla: (message) ->
    console.log "#{message} by #{@name}"

class Bar extends Foo

  constructor: () ->
    Foo.apply this, ["Peter"]

  bla: (message) ->
    Foo.prototype.bla.apply this, [message]

new Bar().bla "No super" # No super by Peter 

I don't like the fact that I need to do this way, but works...

tangzero avatar Oct 10 '14 02:10 tangzero

You can also do this:

    Foo::bla.apply this, [message]

But that isn't the point. This issue isn't that workarounds to not supporting super don't exist, it's that super doesn't work in CSRedux and it works in CoffeeScript proper, which means CSRedux is not a substitute for the CoffeeScript compiler without changing your code.

jordaaash avatar Oct 10 '14 02:10 jordaaash

I agree.

tangzero avatar Oct 10 '14 02:10 tangzero

…or this, which is faster: Foo::bla.call @, message.

Perhaps, the reason why it is called CoffeeScript Redux is that it is missing some of the features… :) Yet omitting super makes the whole class aspect less useful.

davidbonnet avatar Oct 10 '14 08:10 davidbonnet

Since this specific item seems rather easy to fix.. Are the any other obvious omissions from this compiler ?

-----Original Message----- From: "David Bonnet" [email protected] Sent: ‎10.‎10.‎2014 10:40 To: "michaelficarra/CoffeeScriptRedux" [email protected] Cc: "matthiasg" [email protected] Subject: Re: [CoffeeScriptRedux] Fails to compile when subclass constructorcalls super (#244)

…or this, which is faster: Foo::bla.call @, message. Perhaps, the reason why it is called CoffeeScript Redux is that it is missing some of the features… :) Yet omitting super makes the whole class aspect less useful. — Reply to this email directly or view it on GitHub.=

matthiasg avatar Oct 10 '14 20:10 matthiasg