KCL: Fix incorrect error messages (#6883)
**Problem:** KCL's xLine and yLine functions were telling users to supply either "end" or "endAbsolute" arguments. But "end" is not a valid argument for xLine/yLine, it's actually "length" instead. **Cause:** xLine/yLine were using a helper function designed for `line` KCL stdlib functions, which do use `end`. **Solution** Add a new param to the helper function, indicating what the label should be for relative lines. "end" for `line` calls, `length` for x/yline
This commit is contained in:
@ -278,6 +278,7 @@ async fn inner_line(
|
|||||||
end_absolute,
|
end_absolute,
|
||||||
end,
|
end,
|
||||||
tag,
|
tag,
|
||||||
|
relative_name: "end",
|
||||||
},
|
},
|
||||||
exec_state,
|
exec_state,
|
||||||
args,
|
args,
|
||||||
@ -290,6 +291,7 @@ struct StraightLineParams {
|
|||||||
end_absolute: Option<[TyF64; 2]>,
|
end_absolute: Option<[TyF64; 2]>,
|
||||||
end: Option<[TyF64; 2]>,
|
end: Option<[TyF64; 2]>,
|
||||||
tag: Option<TagNode>,
|
tag: Option<TagNode>,
|
||||||
|
relative_name: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StraightLineParams {
|
impl StraightLineParams {
|
||||||
@ -299,6 +301,7 @@ impl StraightLineParams {
|
|||||||
tag,
|
tag,
|
||||||
end: Some(p),
|
end: Some(p),
|
||||||
end_absolute: None,
|
end_absolute: None,
|
||||||
|
relative_name: "end",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn absolute(p: [TyF64; 2], sketch: Sketch, tag: Option<TagNode>) -> Self {
|
fn absolute(p: [TyF64; 2], sketch: Sketch, tag: Option<TagNode>) -> Self {
|
||||||
@ -307,6 +310,7 @@ impl StraightLineParams {
|
|||||||
tag,
|
tag,
|
||||||
end: None,
|
end: None,
|
||||||
end_absolute: Some(p),
|
end_absolute: Some(p),
|
||||||
|
relative_name: "end",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -317,6 +321,7 @@ async fn straight_line(
|
|||||||
end,
|
end,
|
||||||
end_absolute,
|
end_absolute,
|
||||||
tag,
|
tag,
|
||||||
|
relative_name,
|
||||||
}: StraightLineParams,
|
}: StraightLineParams,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
args: Args,
|
args: Args,
|
||||||
@ -335,7 +340,7 @@ async fn straight_line(
|
|||||||
(None, None) => {
|
(None, None) => {
|
||||||
return Err(KclError::Semantic(KclErrorDetails {
|
return Err(KclError::Semantic(KclErrorDetails {
|
||||||
source_ranges: vec![args.source_range],
|
source_ranges: vec![args.source_range],
|
||||||
message: "You must supply either `end` or `endAbsolute` arguments".to_owned(),
|
message: format!("You must supply either `{relative_name}` or `endAbsolute` arguments"),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -447,6 +452,7 @@ async fn inner_x_line(
|
|||||||
end_absolute: end_absolute.map(|x| [x, from.into_y()]),
|
end_absolute: end_absolute.map(|x| [x, from.into_y()]),
|
||||||
end: length.map(|x| [x, TyF64::new(0.0, NumericType::mm())]),
|
end: length.map(|x| [x, TyF64::new(0.0, NumericType::mm())]),
|
||||||
tag,
|
tag,
|
||||||
|
relative_name: "length",
|
||||||
},
|
},
|
||||||
exec_state,
|
exec_state,
|
||||||
args,
|
args,
|
||||||
@ -512,6 +518,7 @@ async fn inner_y_line(
|
|||||||
end_absolute: end_absolute.map(|y| [from.into_x(), y]),
|
end_absolute: end_absolute.map(|y| [from.into_x(), y]),
|
||||||
end: length.map(|y| [TyF64::new(0.0, NumericType::mm()), y]),
|
end: length.map(|y| [TyF64::new(0.0, NumericType::mm()), y]),
|
||||||
tag,
|
tag,
|
||||||
|
relative_name: "length",
|
||||||
},
|
},
|
||||||
exec_state,
|
exec_state,
|
||||||
args,
|
args,
|
||||||
|
Reference in New Issue
Block a user