maxtaco / coffee-script

IcedCoffeeScript
http://maxtaco.github.com/coffee-script
MIT License
727 stars 58 forks source link

ReferenceError: Invalid left-hand side in assignment #128

Open kflu opened 10 years ago

kflu commented 10 years ago

With the below sample:

# test.coffee
f = (s, e) -> s 'you succeeded'

rv = new iced.Rendezvous
f rv.defer msg, rv.defer err
await rv.wait defer which
console.log "got back #{which}"
console.log "msg: #{msg}, err: #{err}"

Upon running with iced test.coffee, it throws:

ReferenceError: Invalid left-hand side in assignment
  at C:\Users\works\kk\k.coffee:19:11
  at ret (C:\Users\AppData\Roaming\npm\node_modules\iced-coffee-script\node_modules\iced-runtime\lib\runtime.js:21:16)
  at f (C:\Users\works\kk\k.coffee:1:15)
  at Object.<anonymous> (C:\Users\works\kk\k.coffee:4:1)
  at Object.<anonymous> (C:\Users\works\kk\k.coffee:1:1)
  at Module._compile (module.js:456:26)

Looking at the compiled js, it has the following snippets, which is obviously wrong (line marked with "XXXX"). However if I change in test.coffee the way how I call the f() function to: f (rv.defer msg), (rv.defer err), it works.

// Generated by IcedCoffeeScript 1.7.1-f
(function() {
  var f, iced, msg, rv, which, __iced_deferrals, __iced_k, __iced_k_noop;

  iced = require('iced-runtime');
  __iced_k = __iced_k_noop = function() {};

  f = function(s, e) {
    return s('you succeeded');
  };

  rv = new iced.Rendezvous;

  f(rv.defer({
    assign_fn: (function(_this) {
      var err;
      return function(__slot_1) {
        return function() {
          msg = arguments[0];
          return __slot_1.defer({
            assign_fn: (function() {
              return function() {
                return err = arguments[0];
              };
            })(),
            lineno: 3,
            context: __iced_deferrals
          }) = arguments[1];  // XXXXXXXXX
        };
      };
    })(this)(rv),
    lineno: 3,
    context: __iced_deferrals
  }));