简体   繁体   English

Ruby版本更改后,Rails Coffescript中的“意外索引”

[英]“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 . 更改红宝石版本( 1.9.3 > 1.9.2 ),突然所有咖啡脚本开始产生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. 当我注释整个脚本时,相同的错误会跳转到下一个/另一个coffeescript文件。

Tried with coffee-rails versions 3.2.1 and 3.2.2. 尝试使用coffee-rails 3.2.1和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. 我找到了造成这种情况的原因,但我不明白为什么它对于不同的Ruby版本应该有所不同。 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. 我的代码中都有很多 ,但是在Ruby降级之后,代码结构就停止了工作。 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 :S

Answer its not longer necessary, but if anyone could explain it... I'd be glad. 回答不再需要的答案,但是如果有人可以解释它,我将很高兴。

This syntax was not allowed "on purpose", if was merely allowed because the compiler refused to generate 'a'(...) . 如果仅因为编译器拒绝生成'a'(...) ,就被允许“故意”使用该语法。 ID block is a call ID block是一个电话

See this issue . 看到这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM