Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add callstacks to generators that can error. #538

Merged
merged 4 commits into from
Aug 31, 2024

Conversation

ChickenProp
Copy link
Contributor

@ChickenProp ChickenProp commented Aug 23, 2024

Previously, val <- Gen.element [] would give an error like

Hedgehog.Gen.element: used with empty Foldable
CallStack (from HasCallStack):
  error, called at src/Hedgehog/Internal/Gen.hs:1197:5 in hedgehog-1.4-FEcjASqhnyiHkb8BJanjYM:Hedgehog.Internal.Gen

Which isn't very helpful. Now the callstack entry points to my own code, instead.

I guess this will need a version bump since it changes types?

I think I got all the generators that are expected to throw errors. Some call error but describe it as internal, and I didn't touch those.

Previously, `val <- Gen.element []` would give an error like

    Hedgehog.Gen.element: used with empty Foldable
    CallStack (from HasCallStack):
      error, called at src/Hedgehog/Internal/Gen.hs:1197:5 in hedgehog-1.4-FEcjASqhnyiHkb8BJanjYM:Hedgehog.Internal.Gen

Which isn't very helpful. Now the callstack entry points to my own code,
instead.
@ChickenProp
Copy link
Contributor Author

Welp, apparently this fails on 8.0.2 :/

I imagine I can fix that somehow (we use withFrozenCallStack elsewhere, so it must be workable). But before I do, to check: do we still want support going that far back? 8.2.1 was released in 2017.

Copy link
Member

@moodmosaic moodmosaic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

The addition of HasCallStack and withFrozenCallStack looks good wrt improving error diagnostics. However, since this change modifies the function signatures, it could potentially break backward compatibility for users with explicit type annotations. So we’ll need to consider a major version bump.

Regarding GHC 8.0.2, I agree that it’s reasonable to drop support, allowing us to focus on more recent releases.

@ChickenProp
Copy link
Contributor Author

Yeah, agree it'll need a major version bump.

I can put either or both of the version bump and dropping 8.0.2 support in this PR if you want, or they can be separate.

@moodmosaic
Copy link
Member

Could be done in the same PR, just separate Git commit. And then we may update the PR title.

9c85082 doesn't compile on it, and 8.2.1 was released in 2017.
@ChickenProp
Copy link
Contributor Author

Okay, done both of those.

Copy link
Member

@moodmosaic moodmosaic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChickenProp, thank you! The changes look good, so I’m happy to approve.

I’ll leave some room for other contributors to review, and if we don’t hear back, we can merge later this week. Hope that's okay! Thanks again for your work on this.

@moodmosaic moodmosaic merged commit 94dfee5 into hedgehogqa:master Aug 31, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants