Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: Don't republish old errors on successful compilation #2427

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

tgodzik
Copy link
Contributor

@tgodzik tgodzik commented Sep 10, 2024

We need to report all problems if a BSP client just connected to the server and never compiled. reportAllPreviousProblems will be set to true in that case.

However, if previously we had an error, which was reverted and got back to the state before the error, we will get a successfull noop compilation, which will not produce any problems.

In this case we don't want to republish everything again, since diagnostics will contain the error which was reverted.

Connected to VirtusLab/scala-cli#2226 where CLI always connected anew.

We need to report all problems if a BSP client just connected to the server and never compiled.
`reportAllPreviousProblems` will be set to true in that case.

However, if previously we had an error, which was reverted and got back to the state before the
error, we will get a successfull noop compilation, which will not produce any problems.

In this case we don't want to republish everything again, since diagnostics will contain the
error which was reverted.

Connected to VirtusLab/scala-cli#2226 where CLI always connected anew.
@tgodzik tgodzik force-pushed the fix-republish-diags branch from 2fc06f5 to 0727b16 Compare September 11, 2024 16:54
@tgodzik tgodzik marked this pull request as ready for review September 12, 2024 16:12
@tgodzik tgodzik requested a review from adpi2 September 12, 2024 16:12
Copy link
Member

@adpi2 adpi2 left a comment

Choose a reason for hiding this comment

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

I am not sure to understand everything. But maybe a noop compilation should clear the errors that were stored in the reporter.

Comment on lines +311 to +312
* In this case we don't want to republish everything again, since diagnostics will contain the
* error which was reverted.
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure to understand this. If the previous was a noop compilation, why would diagnostics contain any error? In other words, I think a noop compilation should clear the diagnostics that were stored anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can also have a noop compilation that was an actual error. If nothing changed we would still have the same exact errors, so no need to recompile.

Copy link
Member

Choose a reason for hiding this comment

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

Okay but if it is a success, we should first clear problemsPerFiles so that it does not contain any error anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would make sense, but then when we have reportAllPreviousProblems set (this is set when first compilation for a target and client is run) then we would not report old warnings, since we would clean it. We can try to clean just the errors out, but we don't know if some warnings weren't generate along those errors.

So in essence, we don't know what exact problems were generated in the compilation before and those are the ones we should clear.

It's much easier to just special case this situation and just report everything in the previous successful compilation. And while I agree with you that something is wrong here, I can't figure out a more sensible solution, all alternative paths seem more complicated and carry their own drawbacks. This might be due to the fact that noop compilation is a bit of a trick, which is not really something that a lot of other tools using zinc do.

@tgodzik
Copy link
Contributor Author

tgodzik commented Sep 17, 2024

I am not sure to understand everything. But maybe a noop compilation should clear the errors that were stored in the reporter.

That's the whole issue actually. If a new client connects (which Scala CLI does every time it's run) and noop compilation is run then if we clear the errors nothing will be reported the new client.

@tgodzik tgodzik merged commit 4d9d369 into scalacenter:main Sep 17, 2024
16 of 17 checks passed
@tgodzik tgodzik deleted the fix-republish-diags branch September 17, 2024 11:40
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.

2 participants