Accept n+ as array lengths (#7212)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -198,7 +198,7 @@ impl Type {
|
||||
hasher.update(ty.compute_digest());
|
||||
match len {
|
||||
crate::execution::types::ArrayLen::None => {}
|
||||
crate::execution::types::ArrayLen::NonEmpty => hasher.update(usize::MAX.to_ne_bytes()),
|
||||
crate::execution::types::ArrayLen::Minimum(n) => hasher.update((-(*n as isize)).to_ne_bytes()),
|
||||
crate::execution::types::ArrayLen::Known(n) => hasher.update(n.to_ne_bytes()),
|
||||
}
|
||||
}
|
||||
|
@ -3336,7 +3336,7 @@ impl fmt::Display for Type {
|
||||
write!(f, "[{ty}")?;
|
||||
match len {
|
||||
ArrayLen::None => {}
|
||||
ArrayLen::NonEmpty => write!(f, "; 1+")?,
|
||||
ArrayLen::Minimum(n) => write!(f, "; {n}+")?,
|
||||
ArrayLen::Known(n) => write!(f, "; {n}")?,
|
||||
}
|
||||
write!(f, "]")
|
||||
|
@ -2968,16 +2968,9 @@ fn array_type(i: &mut TokenSlice) -> ModalResult<Node<Type>> {
|
||||
.parse_next(i)?;
|
||||
close_bracket(i)?;
|
||||
|
||||
let len = if let Some((tok, _, n, plus)) = len {
|
||||
let len = if let Some((_, _, n, plus)) = len {
|
||||
if plus.is_some() {
|
||||
if n != 1 {
|
||||
return Err(ErrMode::Cut(ContextError::from(CompilationError::fatal(
|
||||
tok.as_source_range(),
|
||||
"Non-empty arrays are specified using `1+`, for a fixed-size array use just an integer",
|
||||
))));
|
||||
} else {
|
||||
ArrayLen::NonEmpty
|
||||
}
|
||||
ArrayLen::Minimum(n)
|
||||
} else {
|
||||
ArrayLen::Known(n)
|
||||
}
|
||||
|
Reference in New Issue
Block a user