propensive / contextual

Statically-checked string interpolation in Scala
https://soundness.dev/contextual/
251 stars 23 forks source link

Offer better error message when failing to substitute `Nothing` #74

Open propensive opened 1 year ago

propensive commented 1 year ago

When the type of an expression that's substituted into an interpolated string is Nothing, it probably means that the value is erroneous, and a message has already been emitted. If we can detect that the value is Nothing as the result of an error, then we don't need to emit another message, since doing so distracts from the "real" error. But if the user really does try to substitute Nothing into an interpolated string, we should emit an error.

If it's impossible to distinguish between Nothing and and error, then we should update the error message to indicate that it's probably because of another error.