Skip to content

Adding support for shallow hashes#2

Open
johnlevidy wants to merge 2 commits into
masterfrom
shallow_hash
Open

Adding support for shallow hashes#2
johnlevidy wants to merge 2 commits into
masterfrom
shallow_hash

Conversation

@johnlevidy

Copy link
Copy Markdown
Owner

No description provided.

l = []
for name, type_ in root.fields.items():
if isinstance(type_, mir.DetachedVariant) and type_.is_hash_tag:
l.append(f"{name}=HashVariant")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This crucially prevents recursion and keeps the hash variants shallow?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

yep!

@johnlevidy johnlevidy Feb 5, 2025

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

it's still important to include the type, but that's exactly right: "i dont need to include the inner types in the hash b/c access is protected by the hash"

return visitor.visit_variant_ref(self)

@dataclasses.dataclass(frozen=True)
class HashVariantRef(VariantRef):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is the purpose of this so that we can differentiate between the two?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

yeah, it's either this or a field on variantref

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