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

Array ops pop_left and pop_right should validate that the array type size is not 0 #1521

Open
doug-q opened this issue Sep 4, 2024 · 0 comments

Comments

@doug-q
Copy link
Collaborator

doug-q commented Sep 4, 2024

I expect that currently we will get panics on

array_type(TypeArg::BoundedNat { n: n - 1 }, elem_ty_var.clone());

These ops return an option type, one assumes that failure here means the array had zero size. As is this is unnecessary:

  • if they array's size is TypeArg::BoundedNat{n: 0}, compute_signature should return an error (instead of panicking on the line above).
  • if the array's size is a TypeArg::Variable we fail. We can't do better without arithmetic-in-the-type-system. Note this means that these pop functions are not useful inside functions polymorphic on the size of the array.
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