-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Highlighting locations in lines with unicode on rich terminals #11917
Description
In #11899, @hhugo points out that our current approach of highlighting locations using ^^^^ on the line below is fragile in presence of unicode characters with a non-obvious display width.
$ cat c.ml
let (s : string) = "npiπππ" ^ 2
$ ocamlc -c c.ml
File "c.ml", line 1, characters 33-34:
1 | let (s : string) = "npiπππ" ^ 2
^
Error: This expression has type int but an expression was expected of type
stringThe discussion of #11899 clarifies that it seems unrealistic to be able to compute the "right" width at which to place the ^ on the line below (especially within the compiler distribution with a minimal library footprint).
For rich terminals, we propose instead to stick to location-highlighting formats that are "on-line" in the sense of being overlayed on the line: text font, weight or color, underlining, etc.
Proposal: use underlining to highlight the location in the quoted string.
This is what we use in the toplevel, but not (currently) in the "rich" error reporting format in batch mode.