diff --git a/src/stdlib/pop.rs b/src/stdlib/pop.rs index a8632c805..bcf3782a8 100644 --- a/src/stdlib/pop.rs +++ b/src/stdlib/pop.rs @@ -72,10 +72,19 @@ impl FunctionExpression for PopFn { } fn type_def(&self, state: &state::TypeState) -> TypeDef { - self.value + let mut typedef = self.value .type_def(state) .fallible_unless(Kind::array(Collection::any())) - .restrict_array() + .restrict_array(); + + // Remove last element from type definition if array contains just know elements + if let Some(col) = typedef.kind_mut().as_array_mut() { + if col.unknown_kind().is_undefined() { + col.known_mut().pop_last(); + } + } + + typedef } } @@ -108,7 +117,6 @@ mod tests { Index::from(2) => Kind::integer(), Index::from(3) => Kind::boolean(), Index::from(4) => Kind::float(), - Index::from(5) => Kind::bytes(), }), } @@ -119,9 +127,7 @@ mod tests { Index::from(0) => Kind::integer(), Index::from(1) => Kind::integer(), Index::from(2) => Kind::integer(), - Index::from(3) => Kind::integer(), }), } - ]; }