Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Case splitting breaks with ghc-7.10 unless I use -fdefer-type-errors #438

Closed
DanielG opened this issue Jan 16, 2015 · 12 comments
Closed

Case splitting breaks with ghc-7.10 unless I use -fdefer-type-errors #438

DanielG opened this issue Jan 16, 2015 · 12 comments
Assignees
Milestone

Comments

@DanielG
Copy link
Owner

DanielG commented Jan 16, 2015

@serras In GhcMod.CaseSplit.splits you catch all exceptions and return an empty result if any happen. With ghc-7.10 it seems that type errors are thrown as exceptions (not sure if that was the case before too) as if I remove the exception handler I get a bunch of type errors when running the test suite against "case split"/"works with case expressions".

If i add -fdefer-type-errors using -g everything works as it should.

I'm not sure what would be the best way to fix this I'd rather not have to add a hack to add -fdefer-type-errors do the DynFlags if we're doing case split. If you can confirm that ghc used to just log type errors instead of throwing them then I guess catching and ignoring the relevant exceptions might work?

@DanielG
Copy link
Owner Author

DanielG commented Jan 16, 2015

I don't get how this ever worked typecheckModule is documented to throw exceptions when type checking fails yet the test suite used to work :/

@yanok
Copy link

yanok commented Apr 9, 2015

@DanielG I don't think this is 7.10 specific. I have the same problem with 7.8: case split doesn't work even if I have some holes (and no other errors). I also found that it's because typecheckModule throws an exception. Strangely enough, if I try to do split before doing check it works just fine...

@DanielG
Copy link
Owner Author

DanielG commented Apr 29, 2015

Seems to work now, no idea what I did to break and then fix it. [EDIT: nope still broken]

@DanielG DanielG closed this as completed Apr 29, 2015
@galderz
Copy link

galderz commented Apr 30, 2015

@DanielG Could this explain why it's not working for me? See #472

@yanok Could you be a little more specific on the workaround you used? Did you modify the ghc-insert-template function?

@DanielG
Copy link
Owner Author

DanielG commented Apr 30, 2015

I'll get to that issue, I was looking into it yesterday and then got sidetracked with other stuff. I can't explain it as of yet.

@serras
Copy link
Contributor

serras commented Jul 11, 2015

I have started working on this issue again. The first thing I found out is that in 7.10 they introduced a new compiler option to make typed holes silent. This needs to be on in order to get the case splitting working in presence of holes.

I have changed the code to set this up in 7.10 at serras@f076e22 However, the bad news is that it doesn't work yet in all situations.

If you check a file with holes and then try to split, it doesn't work. The weird thing is the call to split, the errors found in check are thrown as exceptions, even after telling that they should be deferred at run-time. My understanding is that GHC is doing some sort of caching of results, and does not invalidate it when DynFlags change. Did you find this error at any other point in ghc-mod?

@serras
Copy link
Contributor

serras commented Jul 11, 2015

This GHC Trac issue might be relevant.

@DanielG
Copy link
Owner Author

DanielG commented Jul 13, 2015

Awesome, thanks!

@DanielG DanielG added this to the Next release milestone Aug 4, 2015
@DanielG
Copy link
Owner Author

DanielG commented Aug 4, 2015

@serras what do you mean did I find it at another point?

@DanielG
Copy link
Owner Author

DanielG commented Aug 7, 2015

@serras so you have time to look at this with me at some point next week, I'd really like to get ghc-mod released by the end of next week and this issue is a huge blocker.

@serras
Copy link
Contributor

serras commented Aug 10, 2015

I am very sorry about not being very active. Right now I don't have much time to spend on ghc-mod, although as I said before, the bug seems to be related to GHC not invalidating its cache after changing DynFlags. Thus, when one executes check, the errors are reported, but when then refine is needed, those same errors are not reported again, and thus the command does not work.

@DanielG DanielG modified the milestones: v5.3.1.0, v5.3.0.0 Aug 14, 2015
@acowley acowley mentioned this issue Aug 14, 2015
@DanielG DanielG modified the milestones: Whenever, v5.4.0.0 Sep 7, 2015
@DanielG
Copy link
Owner Author

DanielG commented Feb 14, 2016

Figured out what was causing all the case-split/refine stuff to break, it's my favorite problem cache invalidation at work again. Should be fixed in master now, see 2e4c2b5.

@DanielG DanielG modified the milestones: v5.6.0.0, Whenever Feb 14, 2016
@DanielG DanielG self-assigned this Feb 14, 2016
@DanielG DanielG closed this as completed May 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants