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

Match on variable name #7921

Closed
ncannasse opened this issue Mar 5, 2019 · 4 comments
Closed

Match on variable name #7921

ncannasse opened this issue Mar 5, 2019 · 4 comments
Assignees

Comments

@ncannasse
Copy link
Member

Today I was asked why the following now gives a warning:

enum E<T> {
   None;
   Some( v : T );
}

class Test {

static function foo( v : E<Int> ) {
    var a = None;
    return v.match(a); // warning
}

static function main() {
    trace(foo(None)); // true
    trace(foo(Some(55)); // true too !!!
}

}

I think the match should actually be an error here, given it's always true and can induce the confusion between match and equals (which is the original cause of the problem here)

@ncannasse
Copy link
Member Author

And I'm glad it's not a regression : the match was always returning true since 3.4.x ;)

@Simn Simn self-assigned this Mar 5, 2019
@Simn Simn added the regression label Mar 5, 2019
@Simn
Copy link
Member

Simn commented Mar 5, 2019

I'm pretty sure this actually is a regression from some Haxe version.

@Gama11
Copy link
Member

Gama11 commented Mar 5, 2019

3.2.1 gives this:

Main.hx:9: characters 9-16 : This pattern is unused
Main.hx:9: characters 17-18 : Capture variables are not allowed

@ncannasse
Copy link
Member Author

By "regression", I meant that it never worked as Type.enumEq would have.

@Simn Simn closed this as completed in 0a9c2ca Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants