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

Color compiler warnings and errors #4190

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

maurobalbi
Copy link

@maurobalbi maurobalbi commented Oct 23, 2021

Description of the change
This PR addresses #4152.

I haven't updated the golden tests yet, in case you would like to have some changes.

Example output:
error-example

Checklist:

  • Added a file to CHANGELOG.d for this PR (see CHANGELOG.d/README.md)
  • Added myself to CONTRIBUTORS.md (if this is my first contribution)
  • Linked any existing issues or proposals that this pull request should close

@JordanMartinez
Copy link
Contributor

If this was merged, would it affect purescript-psa at all?

@maurobalbi
Copy link
Author

I'm pretty confident that purescript-psa uses the --json-errors flag to invoke purs, in which case this PR should have no effect on purescript-psa.

@JordanMartinez
Copy link
Contributor

@rhendric You originally pushed back against similar work I did in #4156. Do you feel likewise about the work done here?

@rhendric
Copy link
Member

No, my objection to #4156 was that it started to build an interface that overlapped with another interface we were discussing building; I don't see anything like that here. I don't really have an opinion one way or the other about this change.

@JordanMartinez
Copy link
Contributor

I'll check this out and try it out locally sometime in the next few days. Otherwise, this looks good to me.

@JordanMartinez
Copy link
Contributor

in the next few days

That was supposed to be maybe 3 days after I made that comment, but now it's almost been a week. Sorry about that. I'm currently building this PR's binary and going to test it out. However, I have friends coming by, so this might get postponed until tomorrow.

@maurobalbi
Copy link
Author

No worries, all in due course! I'm already happy that this PR is being considered!

@JordanMartinez
Copy link
Contributor

Here's a before and after of a warning and error using the following code:

module Main where

import Prelude

import Effect (Effect)
import Effect.Console (log)

main :: Effect Unit
main = do
  log "🍝"

foo :: Int -> String
foo x = "bar"

footer :: Int -> Int
footer x = "bar"
Type State Image
Warning Before before-warning
Warning After after-warning
Error Before before-error
Error After after-error

Two things immediately stand out:

  • the content of the error message isn't indented like the content of the warning message. While we're here, I think that should be fixed
  • I'm wondering if the warning color should be a slightly different color than what we're already using to highlight types and whatnot in the message. Perhaps a darker color, so that it stands a bit more in contrast to the rest of the message? However, I'm not sure that's needed because of the indentation.

If you're up for fixing the indentation, please do so and I'll approve it after that. If not, I'll approve this now since the PR does what you stated and debating about colors could delay this.

@maurobalbi
Copy link
Author

Thanks for the review, I just checked it again and it looks like the indentation of warnings and errors is consistent. The difference comes from single vs multiple errors/warnings, as seen in the screenshots:

Type Screenshot
Single error image
Multiple errors image
Single warning image
Multiple warnings image

I'm up for aligning those, my preference would be to add the indentation and newline to the single error/warning.
I tried some additional colors for the warnings, but nothing really stood out as a big improvement.
As a reference: https://en.wikipedia.org/wiki/ANSI_escape_code

Overall I guess there's a lot of bikeshedding to be had!

@JordanMartinez
Copy link
Contributor

I'm up for aligning those, my preference would be to add the indentation and newline to the single error/warning.

Ok, please add the indentation for the single error/warning. Let's leave the colors as is. Thanks for doing this!

Copy link
Contributor

@JordanMartinez JordanMartinez left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

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.

None yet

3 participants