Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@guizmaii
Copy link
Member

@guizmaii guizmaii commented Apr 19, 2024

Supersed #8748 (It was easier to create a new PR than to rebase)

The issue this PR is exploring is the following (copy of the original comment where we discovered it):

There's something surprising in this function.

In the previous version of the code, the parenthDepth parameter seems to be misspelled, and so never used 🤔

The parentDepth variable, which is ("correctly spelled" and) used in the algorithm is always the one from the .fold(...) { case Value(parentStack, parentDepth) => ... } context, so is constant.
This means that the recursive calls to findAncestor, when we parentDepth - 1, is always using the same value for parentDepth - 1. No matter how many recursive calls are made, the result of parentDepth - 1 will always be the same 🤔

I'm not quite sure what this algo is doing nor what should be the correct value used in this subtraction 🤔

The issue I have with my change is that it probably changes a behaviour without breaking any test.
It means that:

  1. This behaviour is probably untested
  2. We don't know if the previous behaviour was correct or incorrect
  3. We don't know if the new behaviour is correct or incorrect

🤔

If we consider this new behaviour correct, it would probably be interesting to add a test to validate and "protect" it from future mistake/incorrect evolution

if (childValue == ref.initial) parentFiberRefs
parentFiberRefs.getOrElse(ref, null) match {
case null =>
if (childValue == initialValue) parentFiberRefs
Copy link
Member Author

@guizmaii guizmaii Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what it means to compare this childStack.head.value with this ref.initial 🤔

@jdegoes
Copy link
Member

jdegoes commented Apr 19, 2024

Definitely need a test to codify behavior.

@guizmaii guizmaii changed the title Fix findAncestor's parentDepth parameter usage [WIP] Fix findAncestor's parentDepth parameter usage Apr 20, 2024
@guizmaii
Copy link
Member Author

Superseded by #8779

@guizmaii guizmaii closed this Apr 22, 2024
@guizmaii guizmaii deleted the findAncestor_0 branch April 22, 2024 08:41
guizmaii added a commit to guizmaii/zio that referenced this pull request Apr 23, 2024
guizmaii added a commit to guizmaii/zio that referenced this pull request Apr 26, 2024
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 this pull request may close these issues.

2 participants