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

calling match on an abstract leads to runtime error #5790

Closed
frabbit opened this issue Nov 3, 2016 · 2 comments
Closed

calling match on an abstract leads to runtime error #5790

frabbit opened this issue Nov 3, 2016 · 2 comments
Assignees

Comments

@frabbit
Copy link
Member

frabbit commented Nov 3, 2016

import haxe.ds.Option;

abstract A<T>(T) from T to T {
  public function new (x:T) this = x;
}

class Test {
    static function main() {
        var a = new A(Some(1));
        trace(a.match(Some(1)));
    }
}

Output:

Called from ? line 1
Called from Test.hx line 12
Uncaught exception - Invalid field access : match

see:
http://try-haxe.mrcdk.com/#6104E

@Simn Simn self-assigned this Dec 18, 2016
@Simn Simn added this to the 4.0 milestone Dec 18, 2016
@Simn
Copy link
Member

Simn commented Dec 18, 2016

It picks up this function as a static extension: https://github.com/HaxeFoundation/haxe/blob/development/std/haxe/EnumTools.hx#L201

That's very silly... Part of the problem if your to T which allows the cast to Option<Int>, which in turn unifies with EnumValue. I'm not sure right now how we could tame this.

@Simn
Copy link
Member

Simn commented Jun 5, 2020

This properly fails at compile-time now.

@Simn Simn closed this as completed Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants