Fix the KCL any type and array coercion incorrectly nesting (#6816)
* Add sim test for any type * Fix doc comments to match code * Add array ascription tests * Commit new test output * Fix to not panic when type is undefined * Fix to not panic on use of the any type * Update test and generated output * Fix error message after rebase * Fix subtype of any * Fix KCL to use new keyword args * Fix to not nest MixedArray in HomArray * Update output * Remove all creation of MixedArray and use HomArray instead * Rename MixedArray to Tuple * Fix to coerce arrays the way tuples are done * Restructure to appease the type signature extraction * Fix TS unit test * Update output after switch to HomArray * Update docs * Fix to remove edge case when creating points * Update docs with broken point signature * Fix display of tuples to not collide with arrays * Change push to an array with type mismatch to be an error * Add sim test for push type error * Fix acription to more general array element type * Fix to coerce point types * Change array push to not error when item type differs * Fix coercion tests * Change to only flatten as a last resort and remove flattening tuples * Contort code to appease doc generation * Update docs * Fix coerce axes * Fix flattening test to test arrays instead of tuples * Remove special subtype case for singleton coercion
This commit is contained in:
@ -48,7 +48,7 @@ pub enum KclValue {
|
||||
#[serde(skip)]
|
||||
meta: Vec<Metadata>,
|
||||
},
|
||||
MixedArray {
|
||||
Tuple {
|
||||
value: Vec<KclValue>,
|
||||
#[serde(skip)]
|
||||
meta: Vec<Metadata>,
|
||||
@ -197,7 +197,7 @@ impl From<KclValue> for Vec<SourceRange> {
|
||||
KclValue::Bool { meta, .. } => to_vec_sr(&meta),
|
||||
KclValue::Number { meta, .. } => to_vec_sr(&meta),
|
||||
KclValue::String { meta, .. } => to_vec_sr(&meta),
|
||||
KclValue::MixedArray { meta, .. } => to_vec_sr(&meta),
|
||||
KclValue::Tuple { meta, .. } => to_vec_sr(&meta),
|
||||
KclValue::HomArray { value, .. } => value.iter().flat_map(Into::<Vec<SourceRange>>::into).collect(),
|
||||
KclValue::Object { meta, .. } => to_vec_sr(&meta),
|
||||
KclValue::Module { meta, .. } => to_vec_sr(&meta),
|
||||
@ -228,7 +228,7 @@ impl From<&KclValue> for Vec<SourceRange> {
|
||||
KclValue::Number { meta, .. } => to_vec_sr(meta),
|
||||
KclValue::String { meta, .. } => to_vec_sr(meta),
|
||||
KclValue::Uuid { meta, .. } => to_vec_sr(meta),
|
||||
KclValue::MixedArray { meta, .. } => to_vec_sr(meta),
|
||||
KclValue::Tuple { meta, .. } => to_vec_sr(meta),
|
||||
KclValue::HomArray { value, .. } => value.iter().flat_map(Into::<Vec<SourceRange>>::into).collect(),
|
||||
KclValue::Object { meta, .. } => to_vec_sr(meta),
|
||||
KclValue::Module { meta, .. } => to_vec_sr(meta),
|
||||
@ -252,7 +252,7 @@ impl KclValue {
|
||||
KclValue::Bool { value: _, meta } => meta.clone(),
|
||||
KclValue::Number { meta, .. } => meta.clone(),
|
||||
KclValue::String { value: _, meta } => meta.clone(),
|
||||
KclValue::MixedArray { value: _, meta } => meta.clone(),
|
||||
KclValue::Tuple { value: _, meta } => meta.clone(),
|
||||
KclValue::HomArray { value, .. } => value.iter().flat_map(|v| v.metadata()).collect(),
|
||||
KclValue::Object { value: _, meta } => meta.clone(),
|
||||
KclValue::TagIdentifier(x) => x.meta.clone(),
|
||||
@ -307,7 +307,7 @@ impl KclValue {
|
||||
} => "number(Angle)",
|
||||
KclValue::Number { .. } => "number",
|
||||
KclValue::String { .. } => "string (text)",
|
||||
KclValue::MixedArray { .. } => "mixed array (list)",
|
||||
KclValue::Tuple { .. } => "tuple (list)",
|
||||
KclValue::HomArray { .. } => "array (list)",
|
||||
KclValue::Object { .. } => "object",
|
||||
KclValue::Module { .. } => "module",
|
||||
@ -373,7 +373,7 @@ impl KclValue {
|
||||
|
||||
/// Put the point into a KCL value.
|
||||
pub fn from_point2d(p: [f64; 2], ty: NumericType, meta: Vec<Metadata>) -> Self {
|
||||
Self::MixedArray {
|
||||
Self::Tuple {
|
||||
value: vec![
|
||||
Self::Number {
|
||||
value: p[0],
|
||||
@ -430,7 +430,7 @@ impl KclValue {
|
||||
|
||||
pub fn as_array(&self) -> Option<&[KclValue]> {
|
||||
match self {
|
||||
KclValue::MixedArray { value, .. } | KclValue::HomArray { value, .. } => Some(value),
|
||||
KclValue::Tuple { value, .. } | KclValue::HomArray { value, .. } => Some(value),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -602,7 +602,7 @@ impl KclValue {
|
||||
KclValue::TagDeclarator(tag) => Some(format!("${}", tag.name)),
|
||||
KclValue::TagIdentifier(tag) => Some(format!("${}", tag.value)),
|
||||
// TODO better Array and Object stringification
|
||||
KclValue::MixedArray { .. } => Some("[...]".to_owned()),
|
||||
KclValue::Tuple { .. } => Some("[...]".to_owned()),
|
||||
KclValue::HomArray { .. } => Some("[...]".to_owned()),
|
||||
KclValue::Object { .. } => Some("{ ... }".to_owned()),
|
||||
KclValue::Module { .. }
|
||||
|
Reference in New Issue
Block a user