From c1f3d3ec396492bd36587013aa29fdd9f46d1b21 Mon Sep 17 00:00:00 2001 From: Tad Lispy Date: Thu, 16 Jul 2020 19:11:11 +0200 Subject: [PATCH] Fix: Error when inserting an empty list in manyOf The bug is described in https://github.com/mdgriffith/elm-markup/issues/42, but I would not consider it a fix as it does not address the error message helpfullness. The problem is that in `ExpectManyOf` case of `Mark.Internal.Description.matchExpected` . There are two variables there: - `oneOptions` `twoOptions` In case of updates `oneOptions` will be a list of all valid options. The `twoOptions` will be blocks that are actually inserted. We want to check if all inserted blocks match any of the valid options. But it was the other way around - the test was "all valid options are inserted". Coincidentally when there is only one valid option and at least one block is inserted, the result is the same. That's probably why the problem remained undetected for relatively long time. I ran into it becasue my list was nested in a record (as described in the linked issue) and was initially empty. --- src/Mark/Internal/Description.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mark/Internal/Description.elm b/src/Mark/Internal/Description.elm index 5823695..b2f8301 100644 --- a/src/Mark/Internal/Description.elm +++ b/src/Mark/Internal/Description.elm @@ -863,7 +863,7 @@ matchExpected subExp expected = List.all (matchExpectedOptions twoOptions) oneOptions ( ExpectManyOf oneOptions, ExpectManyOf twoOptions ) -> - List.all (matchExpectedOptions twoOptions) oneOptions + List.all (matchExpectedOptions oneOptions) twoOptions ( ExpectStartsWith oneStart oneRemain, ExpectStartsWith twoStart twoRemain ) -> matchExpected oneStart twoStart