ocaml-flambda / flambda-backend

The Flambda backend project for OCaml
92 stars 65 forks source link

Honor `[@error_message]` attribute even when its location is ghost #2750

Closed ncik-roberts closed 4 days ago

ncik-roberts commented 4 days ago

Make the compiler report the error payload of [@error_message ...] even in the event that the constrained location is a ghost. This better enables ppxes to insert [@error_message ...] themselves, as ppxes often create ghost locations.

Cross-linking with #1943 and #1954.

Most of this feature is a regression test. It's kind of finicky to get [@error_message ...] to work — it only works when certain syntactic constructs appears as the payload of the constraint. (E.g., it works for variants and not for identifiers — the explanation mechanism has an interaction with whether the construct is "inferred", and [@error_message ...] inherits that interaction.) So the test is fairly contrived.

ncik-roberts commented 4 days ago

Oh, I forgot to mention: the first commit adds a regression test, and the second commit fixes it and updates the test output.