Skip to content

Incorrect pattern matching results using OTP 19.0.x on some platforms #5586

Closed

Description

@scouten

I've identified what looks like a bug in pattern matching (function head selection) in OTP 19.0.x, but only on some platforms.

Environment

  • Elixir versions tested: 1.2, 1.3.0, 1.3.2, 1.3.4 (happens in all versions)
  • OTP versions tested: 18.0, 19.0, 19.1, 19.2 (happens only in OTP 19.0)
  • Operating systems tested: Ubuntu 12.04.5 LTS, Mac OS 10.11.6 (happens only on Ubuntu)

Current behavior

A minimal repro case (one file, one test) is available at https://github.com/scouten/otp-pattern-match. This is a very stripped down version of sqlitex, where I first encountered the bug.

If you examine the Travis CI build logs at https://travis-ci.org/scouten/otp-pattern-match/builds/186425073, you'll see that the test fails on OTP 19.0, but succeeds on 18.0, 19.1, and 19.2.

The bug is essentially that the code fails to match the translate_value clause at https://github.com/scouten/otp-pattern-match/blob/master/lib/pattern_match_bug.ex#L11 in my example. It instead falls through to the catch-all clause at line 23 and thus generates an unwanted result.

Expected behavior

Test matches https://github.com/scouten/otp-pattern-match/blob/master/lib/pattern_match_bug.ex#L11 on all OTP versions.

Activity

  1. scouten commented on Dec 23, 2016

    @scouten
    Author

    This is likely an OTP bug (and could well be closed as such), but wanted to make sure Elixir core team was aware of it.

    I will discontinue testing my code on OTP 19.0 for now. 🙂

  2. josevalim commented on Dec 23, 2016

    @josevalim
    Member

    It is a known bug that has been fixed. Here is the test case added to OTP: erlang/otp@8b83bc0

    Since it was fixed on later 19.0 releases, I believe the OS difference is caused by the version in the OS package manager.

    Thanks for the report!

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

Metadata

Metadata

Assignees

No one assigned

    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

      ⌂ Proxy