icerpc/slicec

Set Explicit Discriminants for Errors and Warnings

Opened this issue · 0 comments

Doing this would present 2 advantages:

  1. In the implementation of these diagnostics, we always pass a stringified error code:
    Instead of hard-coding these in, we could compute them using the discriminant.
  2. Compile-time guarantee there aren't any duplicate error codes.
    Right now, it's up to us to make sure we don't pass the same error code for two different enums.
    But if we used discriminants, the Rust compiler ensures there's no duplicate values for us.