Fix meet_2 unwrapping a None when a source focus holds an empty node - #75
Open
imlvts wants to merge 1 commit into
Open
Fix meet_2 unwrapping a None when a source focus holds an empty node#75imlvts wants to merge 1 commit into
imlvts wants to merge 1 commit into
Conversation
`meet_2` guards both sources with `try_as_tagged`, then on the
`Identity` arm unwraps `into_option` on the same value. The two
disagree: `try_as_tagged` answers `Some` for a `BorrowedRc` whatever it
holds, while `into_option` answers `None` when that node is empty. So a
source whose focus holds an empty node passes the guard and panics on
the unwrap. An empty node is what `create_path` leaves behind, so a
read zipper rooted at a dangling path is enough:
a.create_path(&[0]);
wz.meet_2(&a.read_zipper_at_path(&[0]), &b.read_zipper_at_path(&[0]));
The mask on the `Identity` arm says which *operand* the intersection
equals, so an empty operand means an empty intersection: graft nothing
and report `None`. That is what the model specifies for `meet_2` when
either source node is empty.
Regression test: `write_zipper_meet_2_with_an_empty_source_node`, three
shapes for the other operand, both operand orders. Fails before this
change with an `Option::unwrap()` panic.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BZmoASqM5FUuzvJeJaYQjR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
meet_2guards both sources withtry_as_tagged, then on theIdentityarm unwrapsinto_optionon the same value. The two disagree:try_as_taggedanswersSomefor aBorrowedRcwhatever it holds, whileinto_optionanswersNonewhen that node is empty. So a source whose focus holds an empty node passes the guard and panics on the unwrap. An empty node is whatcreate_pathleaves behind, so a read zipper rooted at a dangling path is enough:The mask on the
Identityarm says which operand the intersection equals, so an empty operand means an empty intersection: graft nothing and reportNone. That is what the model specifies formeet_2when either source node is empty.Regression test:
write_zipper_meet_2_with_an_empty_source_node, three shapes for the other operand, both operand orders. Fails before this change with anOption::unwrap()panic.