Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Values in Packed Data #205

Open
jazullo opened this issue Mar 30, 2023 · 1 comment
Open

Incorrect Values in Packed Data #205

jazullo opened this issue Mar 30, 2023 · 1 comment

Comments

@jazullo
Copy link
Collaborator

jazullo commented Mar 30, 2023

Consider this rbtree implementation
Here is the same adapted for GHC
The Gibbon code yields this error (from an assertion that I have defined):

~/llrbt$ ./rbtree_correct.exe
Unequal black heights!
R2 
B1 B4 
** ** B3 ** 
.. .. .. .. ** ** .. .. '#()

Note ** represents leaves and .. represents spaces. Successive lines down represent successive node depths. Children are printed in the order you would expect. The B and R prefixes indicate black and red nodes.

The error message occurs because the tree is incorrect. The GHC adaptation yields B3 as R3, which would resolve the black height invariant. Gibbon yields a black node, I assume during a rotation it obtained the color (represented as a packed bool, true for red) from the wrong location.

It may also be worth rerepresenting the color as packed nullary constructors R | B, this might work around the bug for color but values/integers are likely broken too.

@jazullo
Copy link
Collaborator Author

jazullo commented Mar 30, 2023

In an attempt to circumvent this issue, I replaced the packed boolean with the previously mentioned R | B type, but this seemed to make some things worse. I received L2 typechecking errors across several variations I tried, which seem to stem from the color variable getting lost.
gist

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

No branches or pull requests

1 participant