macrotypes icon indicating copy to clipboard operation
macrotypes copied to clipboard

Improve errors by saving expanded versions within variants of a macro

Open AlexKnauth opened this issue 7 years ago • 0 comments

For example in a function application macro:

(define-typed-syntax app
  [(_ f a ...) ≫
   [⊢ f ≫ f- ⇒ (~→ τ_a ... τ_out)]
   ....]
  [(_ f a ...) ≫
   [⊢ f ≫ f- ⇒ (~case→ τ_f ...)]
   ....])

If the f- result from the first variant can be used as the f- result for the second, then error reporting improves dramatically, because syntax-parse can recognize that the ~→ and the ~case→ pattern are checking the same syntax object, and it can correctly report the error in terms of the one that made the most progress.

Without this "saving" (it's not caching because it's meant to change behavior), you get bad syntax a lot more often, but with this saving, you get the same error messages you would if you put ~!s within the patterns.

AlexKnauth avatar Mar 29 '17 02:03 AlexKnauth