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

Topics: General
Jan 24, 2013 at 11:57 PM

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 :(

Jan 25, 2013 at 12:05 AM
There seem to be issues with getters and using types within the body of the getter with the same name as the getter. Try renaming the "angle" argument...

-----Original Message-----

From: PhotonStorm
Sent: 24 Jan 2013 23:57:46 GMT
To: [email removed]
Subject: 0.8.2 compiler error "left hand side of an assignment expression must be a variable" [typescript:430800]

From: PhotonStorm

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 :(

Jan 25, 2013 at 12:10 AM

Yeah appears that way. There is no way we're going through all of our code to change this though, especially as they've confirmed it as a bug in your thread. Will wait for the fix.

Coordinator
Jan 25, 2013 at 4:37 PM

This sounds like a regression.  We're looking into it.

Coordinator
Jan 25, 2013 at 4:37 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Jan 25, 2013 at 4:44 PM

A bug it may be, but having parameter variables with the same name as the enclosing method (or property setter) strikes me as an unpleasant code smell. No offence meant, this is a new language and patterns, practices, conventions, standards and the like don't exist yet. But still.