Skip to content

Typing issue with abstracts + op overloading #3214

Closed
@waneck

Description

@waneck

The following code:

import neko.Lib;
abstract Int64(Int64_t)
{
    inline private function new(i)
    {
        this = i;
    }

    inline public static function make(a:Int, b:Int):Int64
    {
        return __make(a,b);
    }

    @:op(A*B) inline public function mul_i64(a:Int64):Int64
    {
        return __mul(this,a);
    }

    static var __make:Dynamic->Dynamic->Int64 = null;
    static var __mul:Dynamic->Dynamic->Int64 = null;
}

abstract Int64_t(Dynamic) {}

Main.hx:

class Main
{
    static function main()
    {
        var a = Int64.make(0,0xFFAAFF),
                b = Int64.make(0,0xAAFFAA);
        var c = a * b;
        $type(c);
        $type(a*b);
    }
}

Fails to compile with the following output:

Main.hx:8: characters 10-11 : Int64 should be Int
Main.hx:8: characters 14-15 : Int64 should be Int
Main.hx:9: characters 8-9 : Warning : Int
Main.hx:10: characters 8-9 : Int64 should be Int
Main.hx:10: characters 10-11 : Int64 should be Int
Main.hx:10: characters 8-11 : Warning : Int

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions