typelevel / typelevel/cats-parse

flakey test: X cats.parse.ParserTest.a.flatMap(b) composes as expected parser00

Open
#395 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
245
Forks
51
Avg merge
3h 20m
Merged PRs (30d)
1

Description

I think this is a case of the flatMap optimization exposing a better error message (flatMap where the left is a known value is the same as a product).

==> X cats.parse.ParserTest.a.flatMap(b) composes as expected parser00  0.218s munit.ComparisonFailException: /home/runner/work/cats-parse/cats-parse/core/shared/src/test/scala/cats/parse/ParserTest.scala:1131
[318](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:318)
1130:
[319](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:319)
1131:        assertEquals(indirect, directResult)
[320](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:320)
1132:      }
[321](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:321)
values are not the same
[322](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:322)
=> Obtained
[323](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:323)
Left(
[324](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:324)
  value = Error(
[325](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:325)
    failedAtOffset = 0,
[326](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:326)
    expected = NonEmptyList(
[327](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:327)
      head = OneOfStr(
[328](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:328)
        offset = 0,
[329](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:329)
        strs = List(
[330](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:330)
          " s(\\).YYZ"
[331](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:331)
        )
[332](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:332)
      ),
[333](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:333)
      tail = List(
[334](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:334)
        InRange(
[335](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:335)
          offset = 0,
[336](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:336)
          lower = '\u0000',
[337](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:337)
          upper = '\uffff'
[338](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:338)
        )
[339](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:339)
      )
[340](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:340)
    )
[341](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:341)
  )
[342](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:342)
)
[343](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:343)
=> Diff (- obtained, + expected)
[344](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:344)
     expected = NonEmptyList(
[345](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:345)
-      head = OneOfStr(
[346](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:346)
+      head = InRange(
[347](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:347)
         offset = 0,
[348](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:348)
-        strs = List(
[349](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:349)
-          " s(\\).YYZ"
[350](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:350)
-        )
[351](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:351)
+        lower = '\u0000',
[352](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:352)
+        upper = '\uffff'
[353](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:353)
       ),
[354](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:354)
-      tail = List(
[355](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:355)
-        InRange(
[356](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:356)
-          offset = 0,
[357](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:357)
-          lower = '\u0000',
[358](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:358)
-          upper = '\uffff'
[359](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:359)
-        )
[360](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:360)
-      )
[361](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:361)
+      tail = Nil
[362](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:362)
     )
[363](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:363)

[364](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:364)
Failing seed: w7VthRO-iPVJWFY3rXtWzH4b3xVthbeUio5nWNQeoUA=
[365](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:365)
You can reproduce this failure by adding the following override to your suite:
[366](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:366)

[367](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:367)
  override val scalaCheckInitialSeed = "w7VthRO-iPVJWFY3rXtWzH4b3xVthbeUio5nWNQeoUA="
[368](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:368)

[369](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:369)
Falsified after 1104 passed tests.
[370](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:370)
> ARG_0: GenT(OneOf(List(Map(Void(AnyChar),<function1>), Map(Str( s(\).YYZ),<function1>))))
[371](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:371)
> ARG_1: ""
[372](https://github.com/typelevel/cats-parse/runs/5614705985?check_suite_focus=true#step:7:372)
> ARG_2: org.scalacheck.GenArities$$Lambda$11873/1560244765@4d07dfbe

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with core/shared/src/test/scala/cats/parse/ParserTest.scala at line 1131 and reproduce the property failure using the reported ScalaCheck seed. Compare the indirect and direct results for a.flatMap(b), then inspect the flatMap optimization mentioned in the issue. Done means the test no longer flakes and the two results agree.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.