Skip to content

Conversation

ckipp01
Copy link
Contributor

@ckipp01 ckipp01 commented Apr 10, 2022

This PR makes changes to the existing xsbti.Problem to account for an
optional diagnostic code that the compiler can return for a given
diagnostic and also related information.

Example of DiagnosticCode

Given a piece of code like:

try {}

You'll receive the following:

-- [E002] Syntax Warning: /Users/ckipp/Documents/scala-workspace/dotty-error-index/examples/002_EmptyCatchAndFinallyBlockID.scala:3:2
3 |  try {}
  |  ^^^^^^
  |  A try without catch or finally is equivalent to putting
  |  its body in a block; no exceptions are handled.

The E002 here is the actual code. Right now there would be no
description.

Example of DiagnosticRelatedInformation

Some diagnostics have multiple positions that they need to represent.
You can see an example of this
here in Dotty with the
use of inlining. Instead of needing to rely on including all of that
information in the diagnostic message it can now be extracted out into
a DiagnosticRelatedInformation.

These changes reference the conversation in #6868

@ckipp01 ckipp01 marked this pull request as ready for review April 10, 2022 11:14
* <p>NOTE: To avoid breaking compatibility we provide a default to account for older Scala
* version that do not have codes.
*/
default Optional<DiagnosticCode> diagnosticCode() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this enough information to get sbt to produce errors that look like what dotty natively produce without us having to pass in a rendered string? That would help solve scala/scala3#14691

@eed3si9n
Copy link
Member

@ckipp01 Thanks for the contribution. Could you target 1.7.x branch instead which runs mima, plz?

This PR makes changes to the existing `xsbti.Problem` to account for an
optional diagnostic code that the compiler can return for a given
diagnostic and also related information.

Given a piece of code like:

```scala
try {}
```

You'll receive the following:

```
-- [E002] Syntax Warning: /Users/ckipp/Documents/scala-workspace/dotty-error-index/examples/002_EmptyCatchAndFinallyBlockID.scala:3:2
3 |  try {}
  |  ^^^^^^
  |  A try without catch or finally is equivalent to putting
  |  its body in a block; no exceptions are handled.
```

The `E002` here is the actual code. Right now there would be no
description.

Some diagnostics have multiple positions that they need to represent.
You can see an example of this
[here](scala/scala3#14002) in Dotty with the
use of inlining. Instead of needing to rely on including all of that
information in the diagnostic message it can now be extracted out into
a `DiagnosticRelatedInformation`.

These changes reference the conversation in sbt#6868
@ckipp01 ckipp01 changed the base branch from develop to 0.7 April 12, 2022 08:25
@ckipp01
Copy link
Contributor Author

ckipp01 commented Apr 12, 2022

@ckipp01 Thanks for the contribution. Could you target 1.7.x branch instead which runs mima, plz?

Sure, the rebase isn't clean, so it's just easier for me to close and open another. I'll go ahead and do that.

@ckipp01 ckipp01 closed this Apr 12, 2022
@ckipp01 ckipp01 reopened this Apr 12, 2022
@ckipp01 ckipp01 changed the base branch from 0.7 to develop April 12, 2022 08:31
@ckipp01 ckipp01 closed this Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants