Opened 14 months ago

Last modified 13 months ago

#15512 new feature request

Rewrite rules should be able to produce custom compiler errors

Reported by: ChaiTRex Owned by:
Priority: normal Milestone: 8.6.1
Component: Compiler Version: 8.4.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


It would be nice if rewrite rules could produce compiler errors with custom messages when a certain combination of functions can only produce bottom or some other suitably undesirable outcome.

For example, length . cycle is either never going to terminate or is going to give an error message (e.g., if the input list is empty). It would be nice to be able to tell the programmer that at compile time.

Change History (4)

comment:1 Changed 13 months ago by mpickering

I don't think this is the place of the simple mechanism of rewrite rules.

This can be implemented using a compiler plugin and users could specify rules in the same manner as a rewrite rule.

comment:2 Changed 13 months ago by ChaiTRex

Resolution: fixed
Status: newclosed

OK, no problem.

On these sorts of suggestions (of mine) that I find out are not good ideas, how should I close the tickets? As "invalid"?

Last edited 13 months ago by ChaiTRex (previous) (diff)

comment:3 Changed 13 months ago by ChaiTRex

Resolution: fixed
Status: closednew

comment:4 Changed 13 months ago by simonpj

You could rewrite

forall x. length (cycle x) = error "length of cycle error"

but it would still be a run-time error, not a compile-time error. It's not clear how to achieve the latter. e.g.

let v = length (cycle x)
in if ... then ...v... else True

then v might never be evaluated.

Note: See TracTickets for help on using tickets.