rescript-lang / rescript-compiler

The compiler for ReScript.
https://rescript-lang.org
Other
6.74k stars 448 forks source link

Option to print super errors with relative path #6109

Open rdavison opened 1 year ago

rdavison commented 1 year ago

Could we get an option to print the path in an error message by its relative path instead of its absolute path? It would have a couple of benefits:

1) You could simplify this regex in the tests: https://github.com/rescript-lang/rescript-compiler/blob/d71fcc26d422affff0c9557cf4df2d68a7df30a1/jscomp/build_tests/super_errors/input.js#L26

2) It would make it possible for me to option+click the paths in VS Code. VS Code apparently uniquely identifies files by the path, and if I provide two paths to the same file, it will open the file twice. This is particularly annoying when I have a file opened from the file explorer, which opens the file by its path relative to the workspace root, and then option+click the absolute path in the super error, and it reopens the file in a separate editor. If I don't notice this, then I can easily end up with editors that are out of sync with each other.

For example, I might have an editor open to Table.res, and the compiler the prints a super error like:

We've found a bug for you!
  /home/richard/code/app/src/Table.res:535:61-74

Screenshot 2023-04-03 at 3 15 18 PM

In this screenshot you can see the consequence of option+clicking the absolute path from the super error.

It would be nice to be able to somehow configure the compiler to be able to print a message like:

We've found a bug for you!
  src/Table.res:535:61-74
cristianoc commented 1 year ago

I suspect this issue is for the editor integration. I remember something like this happened in the past, but not recently. What is the compiler version? And would you look for relevant issues in the editor extension repository in case this was already resolved?

aspeddro commented 1 year ago

I didn't get this issue in vscode, but it would be good to use relative paths. In monorepos the paths are long.

Example:

  Syntax error!
  /home/pedro/Desktop/rescript-material-ui/public/rescript-material-ui/src/ButtonGroup.res:62:18-24

  60 │ module Component = {
  61 │   type t
  62 │   external string string => t = "%identity"
  63 │   external callback: (unit => React.element) => t = "%identity"
  64 │   external element: React.element => t = "%identity"

  Did you forget a `:` here? It signals the start of a type
github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.