hughsk / hughsk/flat

Does unflatten enter into infinite recursion on function or array members?

Open
#94 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.8k
Forks
197
PR merge metrics
No merged PRs in 30d

Description

I'm using this library in an F# project (transpiles to JS through using Fable). So unfortunately I have no JS repro (I'm not a JS dev).

`unflatten` is mostly working fine, but it seems to enter into infinite recursion on some objects. This happens even when there is seemingly nothing to unflatten.

I have an array of key-value pairs (React props) that I'm converting into an object, and then I'm using `unflatten` on this object.

This works fine for some prop arrays, such as this:

![image](https://user-images.githubusercontent.com/7766733/73127951-4e6d0c80-3fc8-11ea-924c-d591e4bc94cf.png)

However, for others, such as this, it enters into an infinite recursion:

![image](https://user-images.githubusercontent.com/7766733/73127955-5e84ec00-3fc8-11ea-9d5b-ab74975287a9.png)

![image](https://user-images.githubusercontent.com/7766733/73128095-c76d6380-3fca-11ea-8777-a3e9a6474ae4.png)

As you can see, in both cases, the original prop list (and thus the object) does not contain keys with the delimiter, and there are no sub-objects to recurse into (unless it does something with the function), so AFAIK `unflatten` shouldn't modify anything.

I have tried `safe` without any effect.

The weird thing is, the stack trace seems to come from the `flatten` function, which I do not call:

![image](https://user-images.githubusercontent.com/7766733/73128112-e9ff7c80-3fca-11ea-98ab-323b0811a3c2.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.