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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 16 17:57:18 UTC 2021


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

--- Comment #4 from Dlang Bot <dlang-bot at dlang.rocks> ---
@MoonlightSentinel created dlang/dmd pull request #13310 "[IGNORE] Check if
other code relyies on invalid ErrorExp identity" fixing this issue:

- 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/13310

--


More information about the Digitalmars-d-bugs mailing list