Alvaro Lourenço
Alvaro Lourenço

Reputation: 1341

"unexpected INDENT" in Rails Coffescript after Ruby version change

The Original Problem

Changed ruby version (1.9.3 > 1.9.2) and suddenly all coffeescripts started yielding unexpected INDENT.

I've triple-checked for spaces/tabs inconsistency on files, and this is not the issue. When I comment the entire script, the same bug jumps to the next/another coffeescript file.

Tried with coffee-rails versions 3.2.1 and 3.2.2. No success in both.

Anyone to light a lamp?

More Details

I found what causing this, yet I can't understand why it shoud work differently for different Ruby versions. It's a long story, but here it goes.

I use a trick to declare static or dynamic getters and setters to my classes. This is something like:

Function::dynamic = (prop, desc) ->
  Object.defineProperty @prototype, prop, desc

Function::static = (prop, desc) ->
  Object.defineProperty @, prop, desc

This provides me a way to declare properties like this:

class MyClass
  @static 'accessor'
    get: -> _accessor
    set: (value) -> _acessor = value

I have plenty of this all over my code, but after Ruby downgrade the code structure just stopped working. Now I'll have to add a comma after the method's first parameter. Like:

@static 'accessor',
  get: -> (...)

And this is what it was all about. :S

Answer its not longer necessary, but if anyone could explain it... I'd be glad.

Upvotes: 0

Views: 178

Answers (1)

Ven
Ven

Reputation: 19040

This syntax was not allowed "on purpose", if was merely allowed because the compiler refused to generate 'a'(...). ID block is a call

See this issue.

Upvotes: 1

Related Questions