Remove ListStream type (#14425)

# Description
List values and list streams have the same type (`list<>`). Rather,
streaming is a separate property of the pipeline/command output. This PR
removes the unnecessary `ListStream` type.

# User-Facing Changes
Should be none, except `random dice` now has a more specific output
type.
This commit is contained in:
Ian Manske 2024-11-26 17:35:55 -08:00 committed by GitHub
parent 186c08467f
commit 4edce44689
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 5 additions and 13 deletions

View file

@ -359,7 +359,6 @@ fn nu_value_to_sqlite_type(val: &Value) -> Result<&'static str, ShellError> {
| Type::Custom(_)
| Type::Error
| Type::List(_)
| Type::ListStream
| Type::Range
| Type::Record(_)
| Type::Signature

View file

@ -12,7 +12,7 @@ impl Command for SubCommand {
fn signature(&self) -> Signature {
Signature::build("random dice")
.input_output_types(vec![(Type::Nothing, Type::ListStream)])
.input_output_types(vec![(Type::Nothing, Type::list(Type::Int))])
.allow_variants_without_examples(true)
.named(
"dice",

View file

@ -15,7 +15,6 @@ impl Command for NuCheck {
Signature::build("nu-check")
.input_output_types(vec![
(Type::String, Type::Bool),
(Type::ListStream, Type::Bool),
(Type::List(Box::new(Type::Any)), Type::Bool),
])
// type is string to avoid automatically canonicalizing the path

View file

@ -29,8 +29,6 @@ pub fn type_compatible(lhs: &Type, rhs: &Type) -> bool {
match (lhs, rhs) {
(Type::List(c), Type::List(d)) => type_compatible(c, d),
(Type::ListStream, Type::List(_)) => true,
(Type::List(_), Type::ListStream) => true,
(Type::List(c), Type::Table(table_fields)) => {
if matches!(**c, Type::Any) {
return true;

View file

@ -109,7 +109,7 @@ impl PipelineData {
/// than would be returned by [`Value::get_type()`] on the result of
/// [`.into_value()`](Self::into_value).
///
/// Specifically, a `ListStream` results in [`list stream`](Type::ListStream) rather than
/// Specifically, a `ListStream` results in `list<any>` rather than
/// the fully complete [`list`](Type::List) type (which would require knowing the contents),
/// and a `ByteStream` with [unknown](crate::ByteStreamType::Unknown) type results in
/// [`any`](Type::Any) rather than [`string`](Type::String) or [`binary`](Type::Binary).
@ -117,7 +117,7 @@ impl PipelineData {
match self {
PipelineData::Empty => Type::Nothing,
PipelineData::Value(value, _) => value.get_type(),
PipelineData::ListStream(_, _) => Type::ListStream,
PipelineData::ListStream(_, _) => Type::list(Type::Any),
PipelineData::ByteStream(stream, _) => stream.type_().into(),
}
}

View file

@ -23,7 +23,6 @@ pub enum Type {
Float,
Int,
List(Box<Type>),
ListStream,
#[default]
Nothing,
Number,
@ -121,7 +120,6 @@ impl Type {
Type::Nothing => SyntaxShape::Nothing,
Type::Record(entries) => SyntaxShape::Record(mk_shape(entries)),
Type::Table(columns) => SyntaxShape::Table(mk_shape(columns)),
Type::ListStream => SyntaxShape::List(Box::new(SyntaxShape::Any)),
Type::Any => SyntaxShape::Any,
Type::Error => SyntaxShape::Any,
Type::Binary => SyntaxShape::Binary,
@ -151,7 +149,6 @@ impl Type {
Type::Nothing => String::from("nothing"),
Type::Number => String::from("number"),
Type::String => String::from("string"),
Type::ListStream => String::from("list-stream"),
Type::Any => String::from("any"),
Type::Error => String::from("error"),
Type::Binary => String::from("binary"),
@ -209,7 +206,6 @@ impl Display for Type {
Type::Nothing => write!(f, "nothing"),
Type::Number => write!(f, "number"),
Type::String => write!(f, "string"),
Type::ListStream => write!(f, "list-stream"),
Type::Any => write!(f, "any"),
Type::Error => write!(f, "error"),
Type::Binary => write!(f, "binary"),

View file

@ -23,7 +23,7 @@ impl PluginCommand for ForEach {
fn signature(&self) -> Signature {
Signature::build(self.name())
.input_output_type(Type::ListStream, Type::Nothing)
.input_output_type(Type::list(Type::Any), Type::Nothing)
.required(
"closure",
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),

View file

@ -26,7 +26,7 @@ impl PluginCommand for Generate {
fn signature(&self) -> Signature {
Signature::build(self.name())
.input_output_type(Type::Nothing, Type::ListStream)
.input_output_type(Type::Nothing, Type::list(Type::Any))
.required(
"initial",
SyntaxShape::Any,