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

Add ANSI syntax highlighting to overload matching errors #11755

Open
postmodern opened this issue Jan 20, 2022 · 8 comments
Open

Add ANSI syntax highlighting to overload matching errors #11755

postmodern opened this issue Jan 20, 2022 · 8 comments

Comments

@postmodern
Copy link
Contributor

postmodern commented Jan 20, 2022

Feature Request

In order to improve readability of the overload matching error, the list of overloaded method signatures could be syntax highlighted with ANSI color codes. This would improve the readability of rather verbose method signatures.

Overloads are:
 - Test#test(arg1 : Int32, arg2 : Int32, arg3 : UInt8)
 - Test#test(arg1 : Int, arg2 : Int32, arg3 : Int::Unsigned)
 - Test#test(arg1 : UInt32, arg2 : UInt32, arg3 : UInt32, &block : (UInt32, UInt32, UInt32 -> Int64))

Elements we could highlight:

  • ,
  • :
  • ( )
  • & ->
  • #
  • argument name
  • Type names

I will let others decide what color scheme should be used, or whether ANSI bold or bright colors should be used to highlight specific elements in the method signature.

@wyhaines
Copy link
Contributor

FWIW, I have a PR that I am playing with to do both this and syntax highlighting of the code lines in a backtrace.

Currently:

image

image

@postmodern
Copy link
Contributor Author

Would also be nice to syntax highlight type unions ((Int32 | String | UInt32)). Highlighting the (, ), and | chars in a different color than the type names would help visually break it up.

@wyhaines
Copy link
Contributor

I agree and I will make those additions tomorrow, after I sleep, and then test it on some real code, and then I will drop the images into this thread.

@HertzDevil
Copy link
Contributor

HertzDevil commented Jan 20, 2022

Duplicate of #11106.

@postmodern
Copy link
Contributor Author

postmodern commented Jan 20, 2022

#11106 seems to be about indicating the compatible arguments to find the optimal overload; which is a neat idea. This feature request is just to add basic syntax highlighting to make it easier to read method signatures and type signatures in error output.

@vlazar
Copy link
Contributor

vlazar commented Jan 20, 2022

Also good to keep this comment in mind #11106 (comment)

@straight-shoota
Copy link
Member

straight-shoota commented Jan 20, 2022

Maybe we should really just use Crystal::SyntaxHighlighter::Colorize for all code that is printed by the compiler, including method signatures and type unions etc.

@wyhaines
Copy link
Contributor

wyhaines commented Jan 20, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants