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:
@ -17,9 +17,9 @@ use crate::{
|
||||
/// Returns the point at the end of the given segment.
|
||||
pub async fn segment_end(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag")?;
|
||||
let result = inner_segment_end(&tag, exec_state, args.clone())?;
|
||||
let pt = inner_segment_end(&tag, exec_state, args.clone())?;
|
||||
|
||||
args.make_user_val_from_point(result)
|
||||
args.make_kcl_val_from_point([pt[0].n, pt[1].n], pt[0].ty.clone())
|
||||
}
|
||||
|
||||
/// Compute the ending point of the provided line segment.
|
||||
@ -64,8 +64,11 @@ fn inner_segment_end(tag: &TagIdentifier, exec_state: &mut ExecState, args: Args
|
||||
source_ranges: vec![args.source_range],
|
||||
})
|
||||
})?;
|
||||
let (p, ty) = path.end_point_components();
|
||||
// Docs generation isn't smart enough to handle ([f64; 2], NumericType).
|
||||
let point = [TyF64::new(p[0], ty.clone()), TyF64::new(p[1], ty)];
|
||||
|
||||
Ok(path.get_to().clone())
|
||||
Ok(point)
|
||||
}
|
||||
|
||||
/// Returns the segment end of x.
|
||||
@ -156,9 +159,9 @@ fn inner_segment_end_y(tag: &TagIdentifier, exec_state: &mut ExecState, args: Ar
|
||||
/// Returns the point at the start of the given segment.
|
||||
pub async fn segment_start(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag")?;
|
||||
let result = inner_segment_start(&tag, exec_state, args.clone())?;
|
||||
let pt = inner_segment_start(&tag, exec_state, args.clone())?;
|
||||
|
||||
args.make_user_val_from_point(result)
|
||||
args.make_kcl_val_from_point([pt[0].n, pt[1].n], pt[0].ty.clone())
|
||||
}
|
||||
|
||||
/// Compute the starting point of the provided line segment.
|
||||
@ -203,8 +206,11 @@ fn inner_segment_start(tag: &TagIdentifier, exec_state: &mut ExecState, args: Ar
|
||||
source_ranges: vec![args.source_range],
|
||||
})
|
||||
})?;
|
||||
let (p, ty) = path.start_point_components();
|
||||
// Docs generation isn't smart enough to handle ([f64; 2], NumericType).
|
||||
let point = [TyF64::new(p[0], ty.clone()), TyF64::new(p[1], ty)];
|
||||
|
||||
Ok(path.get_from().to_owned())
|
||||
Ok(point)
|
||||
}
|
||||
|
||||
/// Returns the segment start of x.
|
||||
|
Reference in New Issue
Block a user