1

Closed

0.8.2 compiler error "left hand side of an assignment expression must be a variable"

description

Upgraded to 0.8.2 today and am getting hundreds of errors across our (quite vast) code base. This one was strange though:
    public set angle(angle:number) {

        angle = Kiwi.Utils.FastMath.wrapAngle(angle);

        if (angle !== this._angle)
        {
            this._angle = angle;
            this.buildCSS(true);
        }

    }


It complains about the first line of the method, saying "the left-hand side of an assignment expression must be a variable, property or indexer", which is most strange as 'angle' is clearly a variable passed into the method.

It also complains about the "if" line, saying "Operator !== cannot be applied to types '(angle:number) => any' and 'number'

Which is equally puzzling. Finally the line "this._angle = angle" errors with "Cannot convert '(angle:number) => any' to 'number'"

It appears that getters and setters are basically broken. Is this all related to the bug I saw filed about setters having the same name as variables? We have to roll back to 0.8.1 because of this :(
Closed Jan 28, 2013 at 6:07 PM by RyanCavanaugh

comments

oisin wrote Jan 25, 2013 at 3:57 PM

It looks like it's confusing the property setter method name "angle" with the setter parameter "angle." Clearly the fix is to rename your parameter to "value" or something. I'm not sure if this is a bug or a breaking change (bugfix.) TypeScript already forces us to qualify members with "this" so there should be no ambiguity - but frankly, it is something I would not permit in terms of code style.

-Oisin