[Issue 22514] Invalid duplicate case error when the switched value has errors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 18 18:36:18 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22514

Dlang Bot <dlang-bot at dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Dlang Bot <dlang-bot at dlang.rocks> ---
dlang/dmd pull request #13309 "Fix 22514 - Don't raise invalid duplicate case
errors when the switch..." was merged into stable:

- dcdfb7959e2e1036fbbc7de10b2e663d80b80d3f by MoonlightSentinel:
  Fix 22514 - Don't raise invalid duplicate case errors when the switch...

  ... has other errors.

  The duplicate case checks triggered because #11467 made `ErrorExp` into
  a singleton and hence caused `ErrorExp` == `ErrorExp` to yield true even
  if those errors were caused by different expressions.

  This situation can arise from two different user errors:

  1. the case is faulty, e.g. an unknown variable
  2. the switch'ed value is faulty, causing `implicitCastTo` to generate
     an `ErrorExp`.

  This commit fixes (1) by simply skipping the ducplicated case check for
  `ErrorExp` because it doesn't have enough information. (2) requires the
  case expression to not be coerced into the switched type s.t. we can
  at least detect some errors while also keeping the actual case
  expression to offer helpful diagnostics.

https://github.com/dlang/dmd/pull/13309

--


More information about the Digitalmars-d-bugs mailing list