Skip to content

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

@doug-q

Description

@doug-q

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions