Useless pattern checks with `|` #2508

Closed
andyli opened this Issue Jan 4, 2014 · 2 comments

2 participants

@andyli
Haxe Foundation member

Based on an example at the bottom of http://haxe.org/manual/pattern_matching :

enum Tree<T> {
    Leaf(v:T);
    Node(l:Tree<T>, r:Tree<T>);
}

class Test<T> {
    static function main():Void {
        switch(Leaf("foo")) {
            case Leaf(_)
               | Leaf("foo"): // This pattern is unused
            case Node(l,r):
        }
    }
}

Tested with 568efe5 and the above was compiled without any error.

Changing that to case Leaf(_): case Leaf("foo"): correctly caused a compilation error.

@Simn Simn was assigned Jan 6, 2014
@Simn
Haxe Foundation member

This looks like a regression, but I don't actually know why it was working before. Unfortunately the uselessness checks are based on cases, not on patterns. I'll see if this can be changed without much hassle.

@Simn Simn closed this in c7aff75 Jan 16, 2014
@Simn Simn added a commit that referenced this issue Feb 15, 2014
@Simn Simn add test for issue #2508 cc4ce36
@Simn Simn reopened this Feb 27, 2014
@Simn Simn modified the milestone: 3.2, 3.1.0 Feb 27, 2014
@Simn
Haxe Foundation member

I'll check this again after the 3.1.0 release. I prefer having this broken over the false positives in issue #2610.

@Simn Simn modified the milestone: 3.3, 3.2 May 21, 2014
@Simn Simn added a commit to Simn/haxe that referenced this issue Mar 14, 2016
@Simn Simn rewrite pattern matcher
closes #2508
closes #3621
closes #3816
closes #3937
closes #4247
closes #4677
closes #4689
closes #4745
closes #4846
closes #4907
e4db212
@Simn Simn added a commit to Simn/haxe that referenced this issue Mar 14, 2016
@Simn Simn rewrite pattern matcher
closes #2508
closes #3621
closes #3816
closes #3937
closes #4247
closes #4677
closes #4689
closes #4745
closes #4846
closes #4907
f33232a
@Simn Simn added a commit that closed this issue Mar 17, 2016
@Simn Simn rewrite pattern matcher
closes #2508
closes #3621
closes #3816
closes #3937
closes #4247
closes #4677
closes #4689
closes #4745
closes #4846
closes #4907
12961d0
@Simn Simn closed this in 12961d0 Mar 17, 2016
@Simn Simn added a commit to Simn/haxe that referenced this issue Mar 21, 2016
@Simn Simn rewrite pattern matcher
closes #2508
closes #3621
closes #3816
closes #3937
closes #4247
closes #4677
closes #4689
closes #4745
closes #4846
closes #4907
44c3168
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment