Add implicit param HasCallStack to assertions#1421
Merged
snoyberg merged 1 commit intoyesodweb:masterfrom Jul 20, 2017
sestrella:add_has_call_stack_to_assertions
Merged
Add implicit param HasCallStack to assertions#1421snoyberg merged 1 commit intoyesodweb:masterfrom sestrella:add_has_call_stack_to_assertions
snoyberg merged 1 commit intoyesodweb:masterfrom
sestrella:add_has_call_stack_to_assertions
Conversation
Member
|
Would you be able to switch this over to using conditional compilation for older GHCs? I'd rather that than add another dependency. |
Contributor
Author
|
@snoyberg thank you for the comment. I guess I could copy some of the content (just #if MIN_VERSION_base(4,8,1)
import qualified GHC.Stack as GHC
#endif
#if MIN_VERSION_base(4,9,0)
import GHC.Stack (HasCallStack)
#elif MIN_VERSION_base(4,8,1)
type HasCallStack = (?callStack :: GHC.CallStack)
#else
import GHC.Exts (Constraint)
type HasCallStack = (() :: Constraint)
#endif
type CallStack = [(String, SrcLoc)]
callStack :: HasCallStack => CallStack
#if MIN_VERSION_base(4,9,0)
callStack = drop 1 $ GHC.getCallStack GHC.callStack
#elif MIN_VERSION_base(4,8,1)
callStack = drop 2 $ GHC.getCallStack ?callStack
#else
callStack = []
#endifHowever, I'm actually exposing a hidden package rather than adding a new dependency since |
Contributor
Author
Contributor
Author
|
@snoyberg all changes are in place. |
Member
|
Looks good. Could you also do a minor version bump and update the changelog? |
Contributor
Author
|
@snoyberg sure thing! I just added a new entry to the CHANGELOG and bumped the minor version. Thank you for taking a look. |
snoyberg
approved these changes
Jul 20, 2017
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
yesod-testcurrent error messages looks like follows:The error message is not easy to localize since it points to the module and line number where the assertion is defined instead of the place where it is called.
Adding HasCallStack to each assertion fix the error message since it passes the CallStack to the HUnit matchers used by
yesod-testunder the hood. Here is an example of how an error message looks before and after the changes introduced by this PR:Before
After