PlayScriptRedux / playscript

PlayScript is an ActionScript compatible compiler and Flash compatible runtime that runs in the Mono/.NET environment
Other
17 stars 9 forks source link

Error CS0172: Type of conditional expression cannot be determined as `uint' and `double' convert implicitly to each other (CS0172) #60

Closed sushihangover closed 9 years ago

sushihangover commented 9 years ago

Regression from away3d-core-monomac:

var lsub:Number = (_revolutions< 1)? _subdivision : _subdivision * _revolutions ;

In:

away3d-core-fp11/src/away3d/extrusions/LatheExtrude.as(41,41): Error CS0172: Type of conditional expression cannot be determined as `uint' and `double' convert implicitly to each other (CS0172) (away3d-core-monomac)
sushihangover commented 9 years ago

New tests to track regression:

as/test-as-CS0172-IntDoubleConditional.as as/test-as-CS0172-UIntDoubleConditional.as

// Compiler options: -psstrict+
package {
    public class Foo {
        public static function Main():int {
                var val:int = 1;
                var num:Number = 1.2345;

                // The following SHOULD NOT report this:

                // error CS0172: Type of conditional expression cannot be determined
                // as `int' and `double' convert implicitly to each other

                // but should in C#

                var y:Number = ( num < 1.987 ) ? val : num;
                var z:Number = ( num < 1 ) ? val : val * num;

                return 0;
        }
    }
}
// Compiler options: -psstrict+
package {
    public class Foo {
        public static function Main():int {
                var val:uint = 1;
                var num:Number = 1.2345;
                var i:int;

                // The folliwing SHOULD NOT report this:

                // error CS0172: Type of conditional expression cannot be determined
                // as `uint' and `int' convert implicitly to each other

                // but should in C#

                var y:Number = ( num < 1.987 ) ? val : num;
                var z:Number = ( num < 1 ) ? val : val * num;

                return 0;
        }
    }
}
sushihangover commented 9 years ago

commit 8c17ec00a5cc83c647e54415398bd6d8b894e499 Author: SushiHangover sushihangover@outlook.com Date: Fri Aug 14 23:22:23 2015 -0700

Fixes #60 : conditional expression implicit conversions