Search code examples
livescript

A function inside a class modifies prototype instead of just returning an object


I have this code in LiveScript (1.1.1):

class A
  b = -> { a: 1 b: 2 }

It compiles into this:

var A;
A = (function(){
  A.displayName = 'A';
  var b, prototype = A.prototype, constructor = A;
  b = function(){
    return prototype.a = 1, prototype.b = 2, prototype;
  };
  function A(){}
  return A;
}()); 

Why does b() modify prototype? I expected it to just return a { a: 1, b: 2 } associative array.


Solution

  • It's because of this : https://github.com/gkz/LiveScript/commit/d49b3ee8e8e2d5d7b9f128fa98c210b582e095fe

    Which should probably be removed then, mmh.