Skip to content

Commit

Permalink
Don't count JSON lists as recursion for trace recursion limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
infinisil committed Apr 8, 2021
1 parent 38f9735 commit e3a8d0c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion morpho-checkpoint-node/src/Morpho/Tracing/Verbosity.hs
Expand Up @@ -21,7 +21,9 @@ limitRecursion n (Array xs)
| n <= 0 = (Any True, String "[ ... ]")
| otherwise =
-- Also uses above-described Applicative instance
second Array $ traverse (limitRecursion (n - 1)) xs
-- We don't decrease n here because JSON lists are pretty slim. We're
-- mainly just concerned about objects for the recursion
second Array $ traverse (limitRecursion n) xs
limitRecursion _ v = (Any False, v)

-- | @recursionFilter minRecursion maxBytes value@ returns the result of
Expand Down
2 changes: 1 addition & 1 deletion morpho-checkpoint-node/tests/Test/Morpho/Tracing.hs
Expand Up @@ -35,7 +35,7 @@ returnsIfLimited = property $ \limit value ->

valueDepth :: Value -> Int
valueDepth (Object xs) = 1 + maximum (map valueDepth xs)
valueDepth (Array xs) = 1 + maximum (map valueDepth xs)
valueDepth (Array xs) = 0 + maximum (map valueDepth xs)
valueDepth _ = 0

limitDepth :: Property
Expand Down

0 comments on commit e3a8d0c

Please sign in to comment.