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

[stdlib] Mark ListLiteral.get as unsafe and introduce __getitem__. #3991

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jjvraw
Copy link
Contributor

@jjvraw jjvraw commented Feb 8, 2025

Mark ListLiteral.get as unsafe to make type rebinding more explicit, to help prevent crashes similar to that seen with Tuple.get (#3935). Also addressing #319, introducing __getitem__ by forwarding Tuple.__getitem__.

Signed-off-by: Joshua James Venter <[email protected]>
Signed-off-by: Joshua James Venter <[email protected]>
@@ -854,13 +854,13 @@ struct object(

@parameter
if _type_is_eq[T, Int]():
self._append(value.get[i, Int]())
self._append(value.unsafe_get[i, Int]())
Copy link
Contributor Author

@jjvraw jjvraw Feb 9, 2025

Choose a reason for hiding this comment

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

Question: Alternatively, removing get entirely, following the changes of Tuple?

Suggested change
self._append(value.unsafe_get[i, Int]())
self._append(rebind[Int](value[i]))

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.

1 participant