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

Use MultiMap for RojoRef -> Ref tracking #4

Conversation

kennethloeffler
Copy link

In rojo-rbx#843, there was some hairiness around the semantics of duplicate RojoRefs. The problems basically boil down to limitations of HashMap<RojoRef, Ref>. Creating a duplicate could clobber the original mapping. Removing a duplicate could also either clobber the original mapping, or else fail to update the mapping. I think to get this right,we have to make a slight change to the design.

This PR changes RojoTree.specified_ids_to_refs to MultiMap<RojoRef, Ref> so that Rojo will always do the right thing when it encounters duplicates. This encodes the possibility of duplicates into the data model, simplifying the code. RojoTree::get_specified_id will still reduce all possibilities into a single-valued option, so the overall behavior should stay the same.

Comment on lines +366 to +367
let duped = tree.insert_instance(tree.get_root_id(), snapshot.clone());
assert_eq!(tree.get_specified_id(&custom_ref.clone()), None);
Copy link
Author

Choose a reason for hiding this comment

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

Is this the behavior we want? RojoTree::get_specified_id could just pull out the first element of the multimap entry and return it in the duplicates case, instead of None... not sure if it really matters, tbh

Copy link
Member

Choose a reason for hiding this comment

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

I think it's probably fine. We don't really care too much about the behavior as long as we handle it and emit a message for the user since it's a logic bug on their end.

@Dekkonot Dekkonot merged commit bccec61 into UpliftGames:ref-properties-upstream Feb 6, 2024
@kennethloeffler kennethloeffler deleted the ref-properties-upstream branch February 6, 2024 19:24
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