Uploaded image for project: 'Erlang/OTP'
  1. Erlang/OTP
  2. ERL-1437

case returning wrong value

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: OTP 23
    • Fix Version/s: OTP-23.1.2
    • Component/s: compiler
    • Labels:
      None

      Description

      The attached code snippet contains the following:

      case {length(new_cache), pid == cache_in_use} do
        {0, true} -> 1
        {_, true} -> 2
        _ -> 3
      end

       

      Where `new_cache` is `[2]`, `pid` is `1` and `cache_in_user` is `1`.

       

      Which should return `2`, which it does on OTP-22, however on OTP-23 and beyond, it returns `3`

       

      I have tracked this bug down to the following commit/PR using git bisect:

      https://github.com/erlang/otp/pull/2387/files

       

      It is also worth noting that when inspecting the case with IO.inspect such as:

      case IO.inspect({length(new_cache), pid == cache_in_use}) do
        {0, true} -> 1
        {_, true} -> 2
        _ -> 3
      end

       

      The value 2 is correctly returned.

        Attachments

        1. bug.erl
          0.3 kB
          Gary
        2. bug.exs
          0.3 kB
          Gary

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            gazler Gary
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: