* Replace tag type with tagIdent and tagDecl

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Replace tagIdent with TaggedEdge and TaggedFace

Signed-off-by: Nick Cameron <nrc@ncameron.org>

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2025-06-16 09:10:36 +12:00
committed by GitHub
parent 2b0ced179a
commit 3936017f10
79 changed files with 505 additions and 335 deletions

View File

@ -1232,7 +1232,7 @@ secondSketch = startSketchOn(part001, face = '')
let err = err.as_kcl_error().unwrap();
assert_eq!(
err.message(),
"face requires a value with type `tag`, but found a value with type `string`."
"face requires a value with type `TaggedFace`, but found a value with type `string`."
);
}

View File

@ -351,7 +351,7 @@ fn docs_for_type(ty: &str, kcl_std: &ModData) -> Option<String> {
None
}
fn generate_const_from_kcl(cnst: &ConstData, file_name: String, example_name: String) -> Result<()> {
fn generate_const_from_kcl(cnst: &ConstData, file_name: String, example_name: String, kcl_std: &ModData) -> Result<()> {
if cnst.properties.doc_hidden {
return Ok(());
}
@ -371,11 +371,13 @@ fn generate_const_from_kcl(cnst: &ConstData, file_name: String, example_name: St
"description": cnst.description,
"deprecated": cnst.properties.deprecated,
"type_": cnst.ty,
"type_desc": cnst.ty.as_ref().map(|t| docs_for_type(t, kcl_std).unwrap_or_default()),
"examples": examples,
"value": cnst.value.as_deref().unwrap_or(""),
});
let output = hbs.render("const", &data)?;
let output = cleanup_types(&output, kcl_std);
expectorate::assert_contents(format!("../../docs/kcl-std/{}.md", file_name), &output);
Ok(())
@ -529,7 +531,8 @@ fn cleanup_type_string(input: &str, fmt_for_text: bool, kcl_std: &ModData) -> St
format!("[{prefix}{ty}{suffix}](/docs/kcl-std/types/std-types-number)")
} else if fmt_for_text && ty.starts_with("fn") {
format!("[{prefix}{ty}{suffix}](/docs/kcl-std/types/std-types-fn)")
} else if fmt_for_text && matches!(kcl_std.find_by_name(ty), Some(DocData::Ty(_))) {
// Special case for `tag` because it exists as a type but is deprecated and mostly used as an arg name
} else if fmt_for_text && matches!(kcl_std.find_by_name(ty), Some(DocData::Ty(_))) && ty != "tag" {
format!("[{prefix}{ty}{suffix}](/docs/kcl-std/types/std-types-{ty})")
} else {
format!("{prefix}{ty}{suffix}")
@ -550,7 +553,7 @@ fn test_generate_stdlib_markdown_docs() {
for d in kcl_std.all_docs() {
match d {
DocData::Fn(f) => generate_function_from_kcl(f, d.file_name(), d.example_name(), &kcl_std).unwrap(),
DocData::Const(c) => generate_const_from_kcl(c, d.file_name(), d.example_name()).unwrap(),
DocData::Const(c) => generate_const_from_kcl(c, d.file_name(), d.example_name(), &kcl_std).unwrap(),
DocData::Ty(t) => generate_type_from_kcl(t, d.file_name(), d.example_name(), &kcl_std).unwrap(),
DocData::Mod(m) => generate_mod_from_kcl(m, d.file_name()).unwrap(),
}

View File

@ -359,6 +359,7 @@ impl ConstData {
crate::parsing::ast::types::LiteralValue::Bool { .. } => "boolean".to_owned(),
}),
),
crate::parsing::ast::types::Expr::AscribedExpression(e) => (None, Some(e.ty.to_string())),
_ => (None, None),
};
@ -831,7 +832,7 @@ impl ArgData {
Some("Edge") => Some((index, format!(r#"{label}${{{index}:tag_or_edge_fn}}"#))),
Some("[Edge; 1+]") => Some((index, format!(r#"{label}[${{{index}:tag_or_edge_fn}}]"#))),
Some("Plane") | Some("Solid | Plane") => Some((index, format!(r#"{label}${{{}:XY}}"#, index))),
Some("[tag; 2]") => Some((
Some("[TaggedFace; 2]") => Some((
index + 1,
format!(r#"{label}[${{{}:tag}}, ${{{}:tag}}]"#, index, index + 1),
)),
@ -1098,7 +1099,7 @@ trait ApplyMeta {
self.impl_kind(annotations::Impl::from_str(s).unwrap());
}
}
"deprecated" => {
annotations::DEPRECATED => {
if let Some(b) = p.value.literal_bool() {
self.deprecated(b);
}

View File

@ -281,8 +281,8 @@ mod tests {
length: number(Length),
symmetric?: bool,
bidirectionalLength?: number(Length),
tagStart?: tag,
tagEnd?: tag,
tagStart?: TagDecl,
tagEnd?: TagDecl,
): [Solid; 1+]"#
);
}

View File

@ -17,6 +17,12 @@ layout: manual
{{{description}}}
{{#if type_}}
### Type
`{{type_}}`{{#if type_desc}} - {{{firstLine type_desc}}}{{/if}}
{{/if}}
{{#if examples}}
### Examples

View File

@ -32,6 +32,8 @@ pub(crate) const IMPL_KCL: &str = "kcl";
pub(crate) const IMPL_PRIMITIVE: &str = "primitive";
pub(super) const IMPL_VALUES: [&str; 3] = [IMPL_RUST, IMPL_KCL, IMPL_PRIMITIVE];
pub(crate) const DEPRECATED: &str = "deprecated";
#[derive(Clone, Copy, Eq, PartialEq, Debug, Default)]
pub enum Impl {
#[default]

View File

@ -84,16 +84,16 @@ impl RuntimeType {
RuntimeType::Primitive(PrimitiveType::Face)
}
pub fn tag() -> Self {
RuntimeType::Primitive(PrimitiveType::Tag)
}
pub fn tag_decl() -> Self {
RuntimeType::Primitive(PrimitiveType::TagDecl)
}
pub fn tag_identifier() -> Self {
RuntimeType::Primitive(PrimitiveType::TagId)
pub fn tagged_face() -> Self {
RuntimeType::Primitive(PrimitiveType::TaggedFace)
}
pub fn tagged_edge() -> Self {
RuntimeType::Primitive(PrimitiveType::TaggedEdge)
}
pub fn bool() -> Self {
@ -196,7 +196,7 @@ impl RuntimeType {
RuntimeType::Primitive(PrimitiveType::Number(ty))
}
AstPrimitiveType::Named { id } => Self::from_alias(&id.name, exec_state, source_range)?,
AstPrimitiveType::Tag => RuntimeType::Primitive(PrimitiveType::Tag),
AstPrimitiveType::TagDecl => RuntimeType::Primitive(PrimitiveType::TagDecl),
AstPrimitiveType::ImportedGeometry => RuntimeType::Primitive(PrimitiveType::ImportedGeometry),
AstPrimitiveType::Function(_) => RuntimeType::Primitive(PrimitiveType::Function),
})
@ -383,8 +383,8 @@ pub enum PrimitiveType {
Number(NumericType),
String,
Boolean,
Tag,
TagId,
TaggedEdge,
TaggedFace,
TagDecl,
Sketch,
Solid,
@ -416,9 +416,9 @@ impl PrimitiveType {
PrimitiveType::Axis3d => "3d axes".to_owned(),
PrimitiveType::ImportedGeometry => "imported geometries".to_owned(),
PrimitiveType::Function => "functions".to_owned(),
PrimitiveType::Tag => "tags".to_owned(),
PrimitiveType::TagDecl => "tag declarators".to_owned(),
PrimitiveType::TagId => "tag identifiers".to_owned(),
PrimitiveType::TaggedEdge => "tagged edges".to_owned(),
PrimitiveType::TaggedFace => "tagged faces".to_owned(),
}
}
@ -426,7 +426,8 @@ impl PrimitiveType {
match (self, other) {
(_, PrimitiveType::Any) => true,
(PrimitiveType::Number(n1), PrimitiveType::Number(n2)) => n1.subtype(n2),
(PrimitiveType::TagId, PrimitiveType::Tag) | (PrimitiveType::TagDecl, PrimitiveType::Tag) => true,
(PrimitiveType::TaggedEdge, PrimitiveType::TaggedFace)
| (PrimitiveType::TaggedEdge, PrimitiveType::Edge) => true,
(t1, t2) => t1 == t2,
}
}
@ -442,9 +443,9 @@ impl fmt::Display for PrimitiveType {
PrimitiveType::Number(NumericType::Any) => write!(f, "number(any units)"),
PrimitiveType::String => write!(f, "string"),
PrimitiveType::Boolean => write!(f, "bool"),
PrimitiveType::Tag => write!(f, "tag"),
PrimitiveType::TagDecl => write!(f, "tag declarator"),
PrimitiveType::TagId => write!(f, "tag identifier"),
PrimitiveType::TaggedEdge => write!(f, "tagged edge"),
PrimitiveType::TaggedFace => write!(f, "tagged face"),
PrimitiveType::Sketch => write!(f, "Sketch"),
PrimitiveType::Solid => write!(f, "Solid"),
PrimitiveType::Plane => write!(f, "Plane"),
@ -1207,6 +1208,17 @@ impl KclValue {
KclValue::TagIdentifier { .. } => Ok(self.clone()),
_ => Err(self.into()),
},
PrimitiveType::TaggedEdge => match self {
KclValue::TagIdentifier { .. } => Ok(self.clone()),
_ => Err(self.into()),
},
PrimitiveType::TaggedFace => match self {
KclValue::TagIdentifier { .. } => Ok(self.clone()),
s @ KclValue::String { value, .. } if ["start", "end", "START", "END"].contains(&&**value) => {
Ok(s.clone())
}
_ => Err(self.into()),
},
PrimitiveType::Axis2d => match self {
KclValue::Object { value: values, meta } => {
if values
@ -1295,23 +1307,10 @@ impl KclValue {
KclValue::Function { .. } => Ok(self.clone()),
_ => Err(self.into()),
},
PrimitiveType::TagId => match self {
KclValue::TagIdentifier { .. } => Ok(self.clone()),
_ => Err(self.into()),
},
PrimitiveType::TagDecl => match self {
KclValue::TagDeclarator { .. } => Ok(self.clone()),
_ => Err(self.into()),
},
PrimitiveType::Tag => match self {
KclValue::TagDeclarator { .. } | KclValue::TagIdentifier { .. } | KclValue::Uuid { .. } => {
Ok(self.clone())
}
s @ KclValue::String { value, .. } if ["start", "end", "START", "END"].contains(&&**value) => {
Ok(s.clone())
}
_ => Err(self.into()),
},
}
}
@ -1501,9 +1500,9 @@ impl KclValue {
KclValue::HomArray { ty, value, .. } => {
Some(RuntimeType::Array(Box::new(ty.clone()), ArrayLen::Known(value.len())))
}
KclValue::TagIdentifier(_) => Some(RuntimeType::Primitive(PrimitiveType::TagId)),
KclValue::TagIdentifier(_) => Some(RuntimeType::Primitive(PrimitiveType::TaggedEdge)),
KclValue::TagDeclarator(_) => Some(RuntimeType::Primitive(PrimitiveType::TagDecl)),
KclValue::Uuid { .. } => Some(RuntimeType::Primitive(PrimitiveType::Tag)),
KclValue::Uuid { .. } => Some(RuntimeType::Primitive(PrimitiveType::Edge)),
KclValue::Function { .. } => Some(RuntimeType::Primitive(PrimitiveType::Function)),
KclValue::Module { .. } | KclValue::KclNone { .. } | KclValue::Type { .. } => None,
}

View File

@ -223,7 +223,7 @@ impl PrimitiveType {
PrimitiveType::String => hasher.update(b"string"),
PrimitiveType::Number(suffix) => hasher.update(suffix.digestable_id()),
PrimitiveType::Boolean => hasher.update(b"bool"),
PrimitiveType::Tag => hasher.update(b"tag"),
PrimitiveType::TagDecl => hasher.update(b"TagDecl"),
PrimitiveType::ImportedGeometry => hasher.update(b"ImportedGeometry"),
PrimitiveType::Function(f) => hasher.update(f.compute_digest()),
}

View File

@ -3151,8 +3151,8 @@ pub enum PrimitiveType {
/// A boolean type.
#[serde(rename = "bool")]
Boolean,
/// A tag.
Tag,
/// A tag declaration.
TagDecl,
/// Imported from other CAD system.
ImportedGeometry,
/// `fn`, type of functions.
@ -3167,7 +3167,7 @@ impl PrimitiveType {
("any", None) => Some(PrimitiveType::Any),
("string", None) => Some(PrimitiveType::String),
("bool", None) => Some(PrimitiveType::Boolean),
("tag", None) => Some(PrimitiveType::Tag),
("TagDecl", None) => Some(PrimitiveType::TagDecl),
("number", None) => Some(PrimitiveType::Number(NumericSuffix::None)),
("number", Some(s)) => Some(PrimitiveType::Number(s)),
("ImportedGeometry", None) => Some(PrimitiveType::ImportedGeometry),
@ -3184,7 +3184,7 @@ impl PrimitiveType {
PrimitiveType::ImportedGeometry => "imported geometries".to_owned(),
PrimitiveType::Function(_) => "functions".to_owned(),
PrimitiveType::Named { id } => format!("`{}`s", id.name),
PrimitiveType::Tag => "tags".to_owned(),
PrimitiveType::TagDecl => "tag declarations".to_owned(),
}
}
}
@ -3202,7 +3202,7 @@ impl fmt::Display for PrimitiveType {
}
PrimitiveType::String => write!(f, "string"),
PrimitiveType::Boolean => write!(f, "bool"),
PrimitiveType::Tag => write!(f, "tag"),
PrimitiveType::TagDecl => write!(f, "TagDecl"),
PrimitiveType::ImportedGeometry => write!(f, "ImportedGeometry"),
PrimitiveType::Function(t) => {
write!(f, "fn")?;

View File

@ -11,12 +11,13 @@ use crate::{
types::{ArrayLen, RuntimeType},
ExecState, ExtrudeSurface, KclValue, ModelingCmdMeta, TagIdentifier,
},
std::Args,
std::{sketch::FaceTag, Args},
SourceRange,
};
/// Get the opposite edge to the edge given.
pub async fn get_opposite_edge(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input_edge = args.get_unlabeled_kw_arg("edge", &RuntimeType::tag_identifier(), exec_state)?;
let input_edge = args.get_unlabeled_kw_arg("edge", &RuntimeType::tagged_edge(), exec_state)?;
let edge = inner_get_opposite_edge(input_edge, exec_state, args.clone()).await?;
Ok(KclValue::Uuid {
@ -64,7 +65,7 @@ async fn inner_get_opposite_edge(
/// Get the next adjacent edge to the edge given.
pub async fn get_next_adjacent_edge(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input_edge = args.get_unlabeled_kw_arg("edge", &RuntimeType::tag_identifier(), exec_state)?;
let input_edge = args.get_unlabeled_kw_arg("edge", &RuntimeType::tagged_edge(), exec_state)?;
let edge = inner_get_next_adjacent_edge(input_edge, exec_state, args.clone()).await?;
Ok(KclValue::Uuid {
@ -121,7 +122,7 @@ async fn inner_get_next_adjacent_edge(
/// Get the previous adjacent edge to the edge given.
pub async fn get_previous_adjacent_edge(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let input_edge = args.get_unlabeled_kw_arg("edge", &RuntimeType::tag_identifier(), exec_state)?;
let input_edge = args.get_unlabeled_kw_arg("edge", &RuntimeType::tagged_edge(), exec_state)?;
let edge = inner_get_previous_adjacent_edge(input_edge, exec_state, args.clone()).await?;
Ok(KclValue::Uuid {
@ -177,13 +178,33 @@ async fn inner_get_previous_adjacent_edge(
/// Get the shared edge between two faces.
pub async fn get_common_edge(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let faces: Vec<TagIdentifier> = args.get_kw_arg(
let mut faces: Vec<FaceTag> = args.get_kw_arg(
"faces",
&RuntimeType::Array(Box::new(RuntimeType::tag_identifier()), ArrayLen::Known(2)),
&RuntimeType::Array(Box::new(RuntimeType::tagged_face()), ArrayLen::Known(2)),
exec_state,
)?;
let edge = inner_get_common_edge(faces, exec_state, args.clone()).await?;
if faces.len() != 2 {
return Err(KclError::new_type(KclErrorDetails::new(
"getCommonEdge requires exactly two tags for faces".to_owned(),
vec![args.source_range],
)));
}
fn into_tag(face: FaceTag, source_range: SourceRange) -> Result<TagIdentifier, KclError> {
match face {
FaceTag::StartOrEnd(_) => Err(KclError::new_type(KclErrorDetails::new(
"getCommonEdge requires a tagged face, it cannot use `START` or `END` faces".to_owned(),
vec![source_range],
))),
FaceTag::Tag(tag_identifier) => Ok(*tag_identifier),
}
}
let face2 = into_tag(faces.pop().unwrap(), args.source_range)?;
let face1 = into_tag(faces.pop().unwrap(), args.source_range)?;
let edge = inner_get_common_edge(face1, face2, exec_state, args.clone()).await?;
Ok(KclValue::Uuid {
value: edge,
meta: vec![args.source_range.into()],
@ -191,7 +212,8 @@ pub async fn get_common_edge(exec_state: &mut ExecState, args: Args) -> Result<K
}
async fn inner_get_common_edge(
faces: Vec<TagIdentifier>,
face1: TagIdentifier,
face2: TagIdentifier,
exec_state: &mut ExecState,
args: Args,
) -> Result<Uuid, KclError> {
@ -200,17 +222,11 @@ async fn inner_get_common_edge(
return Ok(id);
}
if faces.len() != 2 {
return Err(KclError::new_type(KclErrorDetails::new(
"getCommonEdge requires exactly two tags for faces".to_string(),
vec![args.source_range],
)));
}
let first_face_id = args.get_adjacent_face_to_tag(exec_state, &faces[0], false).await?;
let second_face_id = args.get_adjacent_face_to_tag(exec_state, &faces[1], false).await?;
let first_face_id = args.get_adjacent_face_to_tag(exec_state, &face1, false).await?;
let second_face_id = args.get_adjacent_face_to_tag(exec_state, &face2, false).await?;
let first_tagged_path = args.get_tag_engine_info(exec_state, &faces[0])?.clone();
let second_tagged_path = args.get_tag_engine_info(exec_state, &faces[1])?;
let first_tagged_path = args.get_tag_engine_info(exec_state, &face1)?.clone();
let second_tagged_path = args.get_tag_engine_info(exec_state, &face2)?;
if first_tagged_path.sketch != second_tagged_path.sketch {
return Err(KclError::new_type(KclErrorDetails::new(
@ -252,7 +268,7 @@ async fn inner_get_common_edge(
KclError::new_type(KclErrorDetails::new(
format!(
"No common edge was found between `{}` and `{}`",
faces[0].value, faces[1].value
face1.value, face2.value
),
vec![args.source_range],
))

View File

@ -440,6 +440,8 @@ pub(crate) fn std_ty(path: &str, fn_name: &str) -> (PrimitiveType, StdFnProps) {
("types", "Edge") => (PrimitiveType::Edge, StdFnProps::default("std::types::Edge")),
("types", "Axis2d") => (PrimitiveType::Axis2d, StdFnProps::default("std::types::Axis2d")),
("types", "Axis3d") => (PrimitiveType::Axis3d, StdFnProps::default("std::types::Axis3d")),
("types", "TaggedEdge") => (PrimitiveType::TaggedEdge, StdFnProps::default("std::types::TaggedEdge")),
("types", "TaggedFace") => (PrimitiveType::TaggedFace, StdFnProps::default("std::types::TaggedFace")),
_ => unreachable!(),
}
}

View File

@ -15,7 +15,7 @@ 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", &RuntimeType::tag_identifier(), exec_state)?;
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tagged_edge(), exec_state)?;
let pt = inner_segment_end(&tag, exec_state, args.clone())?;
args.make_kcl_val_from_point([pt[0].n, pt[1].n], pt[0].ty.clone())
@ -38,7 +38,7 @@ fn inner_segment_end(tag: &TagIdentifier, exec_state: &mut ExecState, args: Args
/// Returns the segment end of x.
pub async fn segment_end_x(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tag_identifier(), exec_state)?;
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tagged_edge(), exec_state)?;
let result = inner_segment_end_x(&tag, exec_state, args.clone())?;
Ok(args.make_user_val_from_f64_with_type(result))
@ -58,7 +58,7 @@ fn inner_segment_end_x(tag: &TagIdentifier, exec_state: &mut ExecState, args: Ar
/// Returns the segment end of y.
pub async fn segment_end_y(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tag_identifier(), exec_state)?;
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tagged_edge(), exec_state)?;
let result = inner_segment_end_y(&tag, exec_state, args.clone())?;
Ok(args.make_user_val_from_f64_with_type(result))
@ -78,7 +78,7 @@ 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", &RuntimeType::tag_identifier(), exec_state)?;
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tagged_edge(), exec_state)?;
let pt = inner_segment_start(&tag, exec_state, args.clone())?;
args.make_kcl_val_from_point([pt[0].n, pt[1].n], pt[0].ty.clone())
@ -101,7 +101,7 @@ fn inner_segment_start(tag: &TagIdentifier, exec_state: &mut ExecState, args: Ar
/// Returns the segment start of x.
pub async fn segment_start_x(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tag_identifier(), exec_state)?;
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tagged_edge(), exec_state)?;
let result = inner_segment_start_x(&tag, exec_state, args.clone())?;
Ok(args.make_user_val_from_f64_with_type(result))
@ -121,7 +121,7 @@ fn inner_segment_start_x(tag: &TagIdentifier, exec_state: &mut ExecState, args:
/// Returns the segment start of y.
pub async fn segment_start_y(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tag_identifier(), exec_state)?;
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tagged_edge(), exec_state)?;
let result = inner_segment_start_y(&tag, exec_state, args.clone())?;
Ok(args.make_user_val_from_f64_with_type(result))
@ -186,7 +186,7 @@ fn inner_last_segment_y(sketch: Sketch, args: Args) -> Result<TyF64, KclError> {
/// Returns the length of the segment.
pub async fn segment_length(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tag_identifier(), exec_state)?;
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tagged_edge(), exec_state)?;
let result = inner_segment_length(&tag, exec_state, args.clone())?;
Ok(args.make_user_val_from_f64_with_type(result))
}
@ -205,7 +205,7 @@ fn inner_segment_length(tag: &TagIdentifier, exec_state: &mut ExecState, args: A
/// Returns the angle of the segment.
pub async fn segment_angle(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tag_identifier(), exec_state)?;
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tagged_edge(), exec_state)?;
let result = inner_segment_angle(&tag, exec_state, args.clone())?;
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, NumericType::degrees())))
@ -227,7 +227,7 @@ fn inner_segment_angle(tag: &TagIdentifier, exec_state: &mut ExecState, args: Ar
/// Returns the angle coming out of the end of the segment in degrees.
pub async fn tangent_to_end(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tag_identifier(), exec_state)?;
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag", &RuntimeType::tagged_edge(), exec_state)?;
let result = inner_tangent_to_end(&tag, exec_state, args.clone()).await?;
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, NumericType::degrees())))

View File

@ -20,7 +20,7 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
let thickness: TyF64 = args.get_kw_arg("thickness", &RuntimeType::length(), exec_state)?;
let faces = args.get_kw_arg(
"faces",
&RuntimeType::Array(Box::new(RuntimeType::tag()), ArrayLen::Minimum(1)),
&RuntimeType::Array(Box::new(RuntimeType::tagged_face()), ArrayLen::Minimum(1)),
exec_state,
)?;

View File

@ -684,7 +684,7 @@ async fn inner_angled_line_to_y(
pub async fn angled_line_that_intersects(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let sketch = args.get_unlabeled_kw_arg("sketch", &RuntimeType::Primitive(PrimitiveType::Sketch), exec_state)?;
let angle: TyF64 = args.get_kw_arg("angle", &RuntimeType::angle(), exec_state)?;
let intersect_tag: TagIdentifier = args.get_kw_arg("intersectTag", &RuntimeType::tag_identifier(), exec_state)?;
let intersect_tag: TagIdentifier = args.get_kw_arg("intersectTag", &RuntimeType::tagged_edge(), exec_state)?;
let offset = args.get_kw_arg_opt("offset", &RuntimeType::length(), exec_state)?;
let tag: Option<TagNode> = args.get_kw_arg_opt("tag", &RuntimeType::tag_decl(), exec_state)?;
let new_sketch =
@ -776,7 +776,7 @@ pub async fn start_sketch_on(exec_state: &mut ExecState, args: Args) -> Result<K
&RuntimeType::Union(vec![RuntimeType::solid(), RuntimeType::plane()]),
exec_state,
)?;
let face = args.get_kw_arg_opt("face", &RuntimeType::tag(), exec_state)?;
let face = args.get_kw_arg_opt("face", &RuntimeType::tagged_face(), exec_state)?;
match inner_start_sketch_on(data, face, exec_state, &args).await? {
SketchSurface::Plane(value) => Ok(KclValue::Plane { value }),

View File

@ -64,10 +64,10 @@ export Z = {
}: Axis3d
/// Identifies the starting face of an extrusion. I.e., the face which is extruded.
export START = 'start'
export START = 'start': TaggedFace
/// Identifies the ending face of an extrusion. I.e., the new face created by an extrusion.
export END = 'end'
export END = 'end': TaggedFace
/// Create a helix.
///

View File

@ -186,7 +186,7 @@ export fn startSketchOn(
/// Profile whose start is being used.
@planeOrSolid: Solid | Plane,
/// Identify a face of a solid if a solid is specified as the input argument (`planeOrSolid`).
face?: tag,
face?: TaggedFace,
): Plane | Face {}
/// Start a new profile at a given point.
@ -231,7 +231,7 @@ export fn startProfile(
@(snippetArray = ["0", "0"])
at: Point2d,
/// Tag this first starting point.
tag?: tag,
tag?: TagDecl,
): Sketch {}
/// Construct a 2-dimensional circle, of the specified radius, centered at
@ -268,7 +268,7 @@ export fn circle(
@(includeInSnippet = true)
diameter?: number(Length),
/// Create a new tag which refers to this circle.
tag?: tag,
tag?: TagDecl,
): Sketch {}
/// Extend a 2-dimensional sketch through a third dimension in order to
@ -375,9 +375,9 @@ export fn extrude(
/// If specified, will also extrude in the opposite direction to 'distance' to the specified distance. If 'symmetric' is true, this value is ignored.
bidirectionalLength?: number(Length),
/// A named tag for the face at the start of the extrusion, i.e. the original sketch.
tagStart?: tag,
tagStart?: TagDecl,
/// A named tag for the face at the end of the extrusion, i.e. the new face created by extruding the original sketch.
tagEnd?: tag,
tagEnd?: TagDecl,
): [Solid; 1+] {}
/// Works just like the `extrude` command, but also twists the sketch around
@ -647,9 +647,9 @@ export fn revolve(
/// If specified, will also revolve in the opposite direction to 'angle' to the specified angle. If 'symmetric' is true, this value is ignored.
bidirectionalAngle?: number(Angle),
/// A named tag for the face at the start of the revolve, i.e. the original sketch.
tagStart?: tag,
tagStart?: TagDecl,
/// A named tag for the face at the end of the revolve.
tagEnd?: tag,
tagEnd?: TagDecl,
): [Solid; 1+] {}
/// Just like `patternTransform`, but works on 2D sketches not 3D solids.
@ -708,7 +708,7 @@ export fn patternTransform2d(
@(impl = std_rust)
export fn getOppositeEdge(
/// The tag of the edge you want to find the opposite edge of.
@edge: tag,
@edge: TaggedEdge,
): Edge {}
/// Get the next adjacent edge to the edge given.
@ -742,7 +742,7 @@ export fn getOppositeEdge(
@(impl = std_rust)
export fn getNextAdjacentEdge(
/// The tag of the edge you want to find the next adjacent edge of.
@edge: tag,
@edge: TaggedEdge,
): Edge {}
/// Get the previous adjacent edge to the edge given.
@ -776,7 +776,7 @@ export fn getNextAdjacentEdge(
@(impl = std_rust)
export fn getPreviousAdjacentEdge(
/// The tag of the edge you want to find the previous adjacent edge of.
@edge: tag,
@edge: TaggedEdge,
): Edge {}
/// Get the shared edge between two faces.
@ -805,7 +805,7 @@ export fn getPreviousAdjacentEdge(
@(impl = std_rust)
export fn getCommonEdge(
/// The tags of the faces you want to find the common edge between.
faces: [tag; 2],
faces: [TaggedFace; 2],
): Edge {}
/// Construct a circle derived from 3 points.
@ -826,7 +826,7 @@ export fn circleThreePoint(
/// 3rd point to derive the circle.
p3: Point2d,
/// Identifier for the circle to reference elsewhere.
tag?: tag,
tag?: TagDecl,
): Sketch {}
/// Create a regular polygon with the specified number of sides that is either inscribed or circumscribed around a circle of the specified radius.
@ -984,9 +984,9 @@ export fn sweep(
/// What is the sweep relative to? Can be either 'sketchPlane' or 'trajectoryCurve'.
relativeTo?: string = 'trajectoryCurve',
/// A named tag for the face at the start of the sweep, i.e. the original sketch.
tagStart?: tag,
tagStart?: TagDecl,
/// A named tag for the face at the end of the sweep.
tagEnd?: tag,
tagEnd?: TagDecl,
): [Solid; 1+] {}
/// Create a 3D surface or solid by interpolating between two or more sketches.
@ -1068,9 +1068,9 @@ export fn loft(
/// Tolerance for the loft operation.
tolerance?: number(Length),
/// A named tag for the face at the start of the loft, i.e. the original sketch.
tagStart?: tag,
tagStart?: TagDecl,
/// A named tag for the face at the end of the loft.
tagEnd?: tag,
tagEnd?: TagDecl,
): Solid {}
/// Repeat a 2-dimensional sketch along some dimension, with a dynamic amount
@ -1184,7 +1184,7 @@ export fn patternCircular2d(
@(impl = std_rust)
export fn segEnd(
/// The line segment being queried by its tag.
@tag: tag,
@tag: TaggedEdge,
): Point2d {}
/// Compute the ending point of the provided line segment along the 'x' axis.
@ -1203,7 +1203,7 @@ export fn segEnd(
@(impl = std_rust)
export fn segEndX(
/// The line segment being queried by its tag.
@tag: tag,
@tag: TaggedEdge,
): number(Length) {}
/// Compute the ending point of the provided line segment along the 'y' axis.
@ -1223,7 +1223,7 @@ export fn segEndX(
@(impl = std_rust)
export fn segEndY(
/// The line segment being queried by its tag.
@tag: tag,
@tag: TaggedEdge,
): number(Length) {}
/// Compute the starting point of the provided line segment.
@ -1254,7 +1254,7 @@ export fn segEndY(
@(impl = std_rust)
export fn segStart(
/// The line segment being queried by its tag.
@tag: tag,
@tag: TaggedEdge,
): Point2d {}
/// Compute the starting point of the provided line segment along the 'x' axis.
@ -1273,7 +1273,7 @@ export fn segStart(
@(impl = std_rust)
export fn segStartX(
/// The line segment being queried by its tag.
@tag: tag,
@tag: TaggedEdge,
): number(Length) {}
/// Compute the starting point of the provided line segment along the 'y' axis.
@ -1293,7 +1293,7 @@ export fn segStartX(
@(impl = std_rust)
export fn segStartY(
/// The line segment being queried by its tag.
@tag: tag,
@tag: TaggedEdge,
): number(Length) {}
/// Extract the 'x' axis value of the last line segment in the provided 2-d sketch.
@ -1356,7 +1356,7 @@ export fn lastSegY(
@(impl = std_rust)
export fn segLen(
/// The line segment being queried by its tag.
@tag: tag,
@tag: TaggedEdge,
): number(Length) {}
/// Compute the angle (in degrees) of the provided line segment.
@ -1377,7 +1377,7 @@ export fn segLen(
@(impl = std_rust)
export fn segAng(
/// The line segment being queried by its tag.
@tag: tag,
@tag: TaggedEdge,
): number(Angle) {}
/// Returns the angle coming out of the end of the segment in degrees.
@ -1454,7 +1454,7 @@ export fn segAng(
@(impl = std_rust)
export fn tangentToEnd(
/// The line segment being queried by its tag.
@tag: tag,
@tag: TaggedEdge,
): number(Angle) {}
/// Extract the provided 2-dimensional sketch's profile's origin value.
@ -1526,7 +1526,7 @@ export fn involuteCircular(
/// If reverse is true, the segment will start from the end of the involute, otherwise it will start from that start.
reverse?: bool = false,
/// Create a new tag which refers to this line.
tag?: tag,
tag?: TagDecl,
): Sketch {}
/// Extend the current sketch with a new straight line.
@ -1563,7 +1563,7 @@ export fn line(
@(includeInSnippet = true)
end?: Point2d,
/// Create a new tag which refers to this line.
tag?: tag,
tag?: TagDecl,
): Sketch {}
/// Draw a line relative to the current origin to a specified distance away
@ -1598,7 +1598,7 @@ export fn xLine(
/// Which absolute X value should this line go to? Incompatible with `length`.
endAbsolute?: number(Length),
/// Create a new tag which refers to this line.
tag?: tag,
tag?: TagDecl,
): Sketch {}
/// Draw a line relative to the current origin to a specified distance away
@ -1628,7 +1628,7 @@ export fn yLine(
/// Which absolute Y value should this line go to? Incompatible with `length`.
endAbsolute?: number(Length),
/// Create a new tag which refers to this line.
tag?: tag,
tag?: TagDecl,
): Sketch {}
/// Draw a line segment relative to the current origin using the polar
@ -1665,7 +1665,7 @@ export fn angledLine(
/// Draw the line along the given angle until it reaches this point along the Y axis. Only one of `length`, `lengthX`, `lengthY`, `endAbsoluteX`, `endAbsoluteY` can be given.
endAbsoluteY?: number(Length),
/// Create a new tag which refers to this line.
tag?: tag,
tag?: TagDecl,
): Sketch {}
/// Draw an angled line from the current origin, constructing a line segment
@ -1694,11 +1694,11 @@ export fn angledLineThatIntersects(
/// Which angle should the line be drawn at?
angle: number(Angle),
/// The tag of the line to intersect with.
intersectTag: tag,
intersectTag: TaggedEdge,
/// The offset from the intersecting line.
offset?: number(Length) = 0mm,
/// Create a new tag which refers to this line.
tag?: tag,
tag?: TagDecl,
): Sketch {}
/// Construct a line segment from the current origin back to the profile's
@ -1732,7 +1732,7 @@ export fn close(
/// The sketch you want to close.
@sketch: Sketch,
/// Create a new tag which refers to this line.
tag?: tag,
tag?: TagDecl,
): Sketch {}
/// Draw a curved line segment along an imaginary circle.
@ -1789,7 +1789,7 @@ export fn arc(
/// Where should this arc end? Requires `interiorAbsolute`. Incompatible with `angleStart` or `angleEnd`.
endAbsolute?: Point2d,
/// Create a new tag which refers to this arc.
tag?: tag,
tag?: TagDecl,
): Sketch {}
/// Starting at the current sketch's origin, draw a curved line segment along
@ -1862,7 +1862,7 @@ export fn tangentialArc(
/// Offset of the arc. `radius` must be given. Incompatible with `end` and `endAbsolute`.
angle?: number(Angle),
/// Create a new tag which refers to this arc.
tag?: tag,
tag?: TagDecl,
): Sketch {}
/// Draw a smooth, continuous, curved line segment from the current origin to
@ -1910,7 +1910,7 @@ export fn bezierCurve(
/// Coordinate on the plane at which this line should end.
endAbsolute?: Point2d,
/// Create a new tag which refers to this line.
tag?: tag,
tag?: TagDecl,
): Sketch {}
/// Use a 2-dimensional sketch to cut a hole in another 2-dimensional sketch.

View File

@ -73,7 +73,7 @@ export fn fillet(
/// The tolerance for this fillet
tolerance?: number(Length),
/// Create a new tag which refers to this fillet
tag?: tag,
tag?: TagDecl,
): Solid {}
/// Cut a straight transitional edge along a tagged path.
@ -148,7 +148,7 @@ export fn chamfer(
/// The paths you want to chamfer
tags: [Edge; 1+],
/// Create a new tag which refers to this chamfer
tag?: tag,
tag?: TagDecl,
): Solid {}
/// Remove volume from a 3-dimensional shape such that a wall of the
@ -304,7 +304,7 @@ export fn shell(
/// The thickness of the shell
thickness: number(Length),
/// The faces you want removed
faces: [tag; 1+],
faces: [TaggedFace; 1+],
): [Solid] {}

View File

@ -65,7 +65,7 @@ export type string
///
/// ### Tag Declaration
///
/// The syntax for declaring a tag is `$myTag` you would use it in the following
/// The syntax for declaring a tag is `$myTag`. You would use it in the following
/// way:
///
/// ```norun,inline
@ -86,14 +86,6 @@ export type string
/// |> close()
/// ```
///
/// ### Tag Identifier
///
/// As per the example above you can use the tag identifier to get a reference to the
/// tagged object. The syntax for this is `myTag`.
///
/// In the example above we use the tag identifier to get the angle of the segment
/// `segAng(rectangleSegmentA001)`.
///
/// ### Tag Scope
///
/// Tags are scoped globally if in the root context meaning in this example you can
@ -109,7 +101,8 @@ export type string
/// |> angledLine(
/// angle = segAng(rectangleSegmentA001) - 90,
/// length = 196.99,
/// tag = $rectangleSegmentB001)
/// tag = $rectangleSegmentB001
/// )
/// |> angledLine(
/// angle = segAng(rectangleSegmentA001),
/// length = -segLen(rectangleSegmentA001),
@ -137,12 +130,12 @@ export type string
/// |> angledLine(angle = 0, length = 191.26, tag = $rectangleSegmentA001)
/// |> angledLine(
/// angle = segAng(rectangleSegmentA001) - 90deg,
/// length = 196.99
/// length = 196.99,
/// tag = $rectangleSegmentB001,
/// )
/// |> angledLine(
/// angle = segAng(rectangleSegmentA001),
/// length = -segLen(rectangleSegmentA001)
/// length = -segLen(rectangleSegmentA001),
/// tag = $rectangleSegmentC001,
/// )
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
@ -161,7 +154,32 @@ export type string
/// the `rect` function. This is because the `rect` function is returning the
/// sketch group that contains the tags.
@(impl = primitive)
export type tag
export type TagDecl
/// A tag which references a line, arc, or other edge in a sketch or an edge of a solid.
///
/// Created by using a tag declarator (see the docs for `TagDecl`). Can be used where an `Edge` is
/// required.
///
/// If a line in a sketch is tagged and then the sketch is extruded, the tag is a `TaggedEdge` before
/// extrusion and a `TaggedFace` after extrusion.
@(impl = std_rust)
export type TaggedEdge
/// A tag which references a face of a solid, including the distinguished tags `START` and `END`.
///
/// Created by using a tag declarator (see the docs for `TagDecl`).
///
/// If a line in a sketch is tagged and then the sketch is extruded, the tag is a `TaggedEdge` before
/// extrusion and a `TaggedFace` after extrusion.
@(impl = std_rust)
export type TaggedFace
/// Reference a previously created tag. Used much like a variable.
///
/// Prefer to use `TaggedEdge` or `TaggedFace`. For more details on tags, see the docs for `TagDecl`.
@(deprecated = true)
export type tag = TaggedEdge
/// Represents geometry which is defined using some other CAD system and imported into KCL.
@(impl = primitive)

View File

@ -4,8 +4,8 @@ description: Error from executing panic_repro_cube.kcl
---
KCL Semantic error
× semantic: This function expected the input argument to be tag identifier
but it's actually of type tag
× semantic: The input argument of `getNextAdjacentEdge` requires a value
with type `TaggedEdge`, but found a unique ID (uuid) (with type `Edge`).
╭─[43:5]
42 │ // these double wrapped functions are the point of this test
43 │ getNextAdjacentEdge(getNextAdjacentEdge(seg01)),
@ -16,8 +16,9 @@ KCL Semantic error
╰────
╰─▶ KCL Semantic error
× semantic: This function expected the input argument to be tag
identifier but it's actually of type tag
× semantic: The input argument of `getNextAdjacentEdge` requires a
value with type `TaggedEdge`, but found a unique ID (uuid) (with
│ type `Edge`).
╭─[43:25]
42 │ // these double wrapped functions are the point of this test
43 │ getNextAdjacentEdge(getNextAdjacentEdge(seg01)),