Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neko UInt cast error #8726

Closed
sonygod opened this issue Aug 31, 2019 · 6 comments

Comments

@sonygod
Copy link

commented Aug 31, 2019

it's seem all cast between ( Int,Uint) and Bool all wrong .

 package;

import neko.Lib;

/**
* ...
* @author sonygod
*/
class Main 
{
    
    static function main() 
    {
            
        var b = false;
        
        var c:UInt = cast(b, UInt);//neko target still error
        var d:Int = cast(b, Int);//neko target still error
        trace(c);
    }
    
}
@sonygod

This comment has been minimized.

Copy link
Author

commented Aug 31, 2019

@RealyUniqueName

This comment has been minimized.

Copy link
Member

commented Aug 31, 2019

It's the designed behavior of safe cast. Trying to cast to an unrelated type (Bool to UInt or Int in your sample) should throw an error: https://haxe.org/manual/expression-cast-safe.html

@sonygod

This comment has been minimized.

Copy link
Author

commented Aug 31, 2019

why close? @RealyUniqueName

but Hashlink can safe cast from bool to int

@sonygod

This comment has been minimized.

Copy link
Author

commented Aug 31, 2019

image

@Aurel300

This comment has been minimized.

Copy link
Contributor

commented Aug 31, 2019

That last picture looks more like the error to me @sonygod. Bool and (U)Int are not compatible, you should need something like someBool ? 1 : 0 in general.

@RealyUniqueName

This comment has been minimized.

Copy link
Member

commented Aug 31, 2019

Yeah, that's a bug in Hashlink.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.