Skip to content

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

Closed
@scouten

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.

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