ocaml-flambda / flambda-backend

The Flambda backend project for OCaml
93 stars 67 forks source link

Make `-error_size` directly about length of printed error #2700

Closed riaqn closed 3 weeks ago

riaqn commented 3 weeks ago

Currently the compiler accepts a -error_size argument which takes an integer (defaults to 500) as the limit on error message context. Error context longer than that will be printed as ... instead.

However, the limit is not on the printing, but on the marshaled binary. As we introduce complex data structures to value_description, marshaled size is no longer a good indication of printed size.

This PR replaces that with real printing: we now count the length of the printing and compare that with error_size. Indentation is not counted, but spaces and newlines are.

I've decided that with the new metric, error_size defaulting to 256 is a good balance point. Some tests are updated as a result.