Clean up tagToEnum# and dataToTag# rules
Needs RevisionPublic

Authored by dfeuer on Oct 1 2017, 11:37 AM.

Details

Reviewers
bgamari
austin
Summary
  • Make our invariants more explicit; add an assertion to verify.
  • Rewrite calls of tagToEnum# to known-invalid tags into error calls.
dfeuer created this revision.Oct 1 2017, 11:37 AM
dfeuer added inline comments.Oct 1 2017, 11:39 AM
compiler/prelude/PrelRules.hs
883–884

Remove this second comment; that's not implemented yet.

dfeuer updated this revision to Diff 14221.Oct 1 2017, 9:31 PM

Swap order

dfeuer updated this revision to Diff 14222.Oct 1 2017, 9:37 PM

Make the swap right

dfeuer updated this revision to Diff 14223.Oct 1 2017, 9:38 PM

Really this time

dfeuer updated this revision to Diff 14224.Oct 1 2017, 9:39 PM

Kill a warning

dfeuer marked an inline comment as done.Oct 2 2017, 2:24 AM
bgamari requested changes to this revision.Oct 3 2017, 10:10 AM

Looks reasonable to me. One question inline. Might we want a test for this?

compiler/prelude/PrelRules.hs
901

Is there any good reason not to simply panic here (and perhaps below)?

This revision now requires changes to proceed.Oct 3 2017, 10:10 AM
dfeuer added inline comments.Oct 3 2017, 10:19 AM
compiler/prelude/PrelRules.hs
901

I don't think we want to panic for an out-of-bound tag, no. But I believe these WARN pragmas only work when GHC is compiled for debugging. It might make sense to upgrade to whatever mechanism would produce the warning more broadly. We might want to panic for the inappropriate type case that was already there; I'm really not sure if that code is supposed to be reachable at the moment.

austin resigned from this revision.Nov 9 2017, 5:40 PM