4

I have a really simple coffescript class:

class Bar
   foo: ->
      console.log('bar')

Which when compiled using coffee -c bar.coffee is being compiled into

(function() {
  class(Bar({
    foo: function() {
      return console.log('bar');
    }
  }));
}).call(this);

If it makes any difference I'm in Windows and the exact same coffeescript compiles correctly using SassAndCoffee. I have tried a number of different compilers (Node.exe + latest coffescript source, Coffee.exe, etc) but all are showing the same behaviour. Has anyone got any thoughts?

6
  • Sadly, no. Compiles fine for me (coffeescript v 1.1.1), sorry. I also ran the coffee.exe you linked to under Windows XP and it worked fine. Are you sure you don't have a spaces-vs-tabs issue in your original file? Commented Sep 1, 2011 at 17:06
  • As Elf suggests, the only way I can see this issue arising is if your file has some very unusual whitespace in it. I'd try retyping the code in a different editor. Commented Sep 1, 2011 at 17:21
  • @Trevor - I tried all manner of weird tabs-vs-spaces things in the source sample and Coffee still accepted it fine and produced the same results every time. Under linux, tho. Commented Sep 1, 2011 at 18:32
  • 1
    Check bar.coffee's charset and BOM. What does (class) compile to? Commented Sep 1, 2011 at 23:06
  • 1
    Sure. And, dammit, I ought to be able to give you a 'good citizen' reputation award for suggesting it. Thanks! Commented Sep 9, 2011 at 16:16

1 Answer 1

2

James, check and see if you have unusual whitespace in your code that's confusing Coffeescript's parser. Since Coffeescript is a whitespace-delimited language (usually), a tabs-vs-spaces mistake might be the source of your error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.