#1453 Can't use overridden 'set' method in JavaScript

Yuri Strot Sun 20 Mar 2011

I found an issue in the JavaScript generator. If you have following class:

class Simple
{
  Int v
  {
    set
    {
      if (it < 0) it = 0;
      &v = it;
    }
  }
}

And then try to use it:

s := Simple()
s.v += 5

You will get Uncaught ReferenceError: Invalid left-hand side in assignment exception. The problem in the generated JavaScript:

var s = fan.hello.Simple.make();
s.v() = fan.sys.Int.plus(s.v(),5);

Note: without overridden set it works fine.

andy Mon 21 Mar 2011

I believe this is actually a bug in the shortcut assignment generation: #1387

If so, then this should work:

s := Simple
s.v = s.v + 5

Yuri Strot Mon 21 Mar 2011

Yep, this is exactly my issue and I've used such workaround. OK, waiting for the fix.

Login or Signup to reply.