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

NRE when printing failure report with a generated None value #381

Closed
samritchie opened this issue Nov 18, 2021 · 3 comments · Fixed by #382
Closed

NRE when printing failure report with a generated None value #381

samritchie opened this issue Nov 18, 2021 · 3 comments · Fixed by #382

Comments

@samritchie
Copy link

I’m seeing crashes when rendering the failure report for a property with a Gen.option that has generated None. A minimal failing case (using NUnit):

    [<Test>]
    member _.TestOptionReport () =
        property {
            let! opt = Gen.option (Gen.int32 (Range.linear 0 10))
            return opt.IsSome
        }
        |> Property.check

throws the following:

 Error Message:
   System.NullReferenceException : Object reference not set to an instance of an object.
  Stack Trace:
     at System.Object.GetType()
   at Hedgehog.Property.prepareForPrinting@103(Object value)
   at Hedgehog.Property.printValue[a](a value)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.map@75.DoMoveNext(b& curr) in D:\a\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 78
   at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System.Collections.IEnumerator.MoveNext() in D:\a\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 64
   at Microsoft.FSharp.Collections.SeqModule.Iterate[T](FSharpFunc`2 action, IEnumerable`1 source) in D:\a\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 496
   at Hedgehog.ReportModule.renderFailed(FailureData failure, Report report)
   at Hedgehog.ReportModule.tryRaise(Report report)
   at Hedgehog.Property.check(Property`1 p)

I’m using dotnet 6.0.100, macOS 11.6.1, Hedgehog 0.11, NUnit 3.13.2, NUnitTestAdapter 4.1

@TysonMN
Copy link
Member

TysonMN commented Nov 19, 2021

PR #382 fixes this bug and release 0.11.1 contains the fix

@TysonMN
Copy link
Member

TysonMN commented Nov 19, 2021

Thanks @samritchie for the bug report and simple reproduction :)

@samritchie
Copy link
Author

Thanks for the quick fix!

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 a pull request may close this issue.

2 participants