This reverts commit e27840219b.
This commit is contained in:
@ -353,7 +353,6 @@ impl Node<CallExpressionKw> {
|
||||
|
||||
// Build a hashmap from argument labels to the final evaluated values.
|
||||
let mut fn_args = HashMap::with_capacity(self.arguments.len());
|
||||
let mut tag_declarator_args = Vec::new();
|
||||
for arg_expr in &self.arguments {
|
||||
let source_range = SourceRange::from(arg_expr.arg.clone());
|
||||
let metadata = Metadata { source_range };
|
||||
@ -361,12 +360,8 @@ impl Node<CallExpressionKw> {
|
||||
.execute_expr(&arg_expr.arg, exec_state, &metadata, StatementKind::Expression)
|
||||
.await?;
|
||||
fn_args.insert(arg_expr.label.name.clone(), Arg::new(value, source_range));
|
||||
if let Expr::TagDeclarator(td) = &arg_expr.arg {
|
||||
tag_declarator_args.push((td.inner.clone(), source_range));
|
||||
}
|
||||
}
|
||||
let fn_args = fn_args; // remove mutability
|
||||
let tag_declarator_args = tag_declarator_args; // remove mutability
|
||||
|
||||
// Evaluate the unlabeled first param, if any exists.
|
||||
let unlabeled = if let Some(ref arg_expr) = self.unlabeled {
|
||||
@ -392,7 +387,7 @@ impl Node<CallExpressionKw> {
|
||||
FunctionKind::Core(func) => {
|
||||
// Attempt to call the function.
|
||||
let mut result = func.std_lib_fn()(exec_state, args).await?;
|
||||
update_memory_for_tags_of_geometry(&mut result, &tag_declarator_args, exec_state)?;
|
||||
update_memory_for_tags_of_geometry(&mut result, exec_state)?;
|
||||
Ok(result)
|
||||
}
|
||||
FunctionKind::UserDefined => {
|
||||
@ -440,7 +435,6 @@ impl Node<CallExpression> {
|
||||
let fn_name = &self.callee.name;
|
||||
|
||||
let mut fn_args: Vec<Arg> = Vec::with_capacity(self.arguments.len());
|
||||
let mut tag_declarator_args = Vec::new();
|
||||
|
||||
for arg_expr in &self.arguments {
|
||||
let metadata = Metadata {
|
||||
@ -450,19 +444,15 @@ impl Node<CallExpression> {
|
||||
.execute_expr(arg_expr, exec_state, &metadata, StatementKind::Expression)
|
||||
.await?;
|
||||
let arg = Arg::new(value, SourceRange::from(arg_expr));
|
||||
if let Expr::TagDeclarator(td) = arg_expr {
|
||||
tag_declarator_args.push((td.inner.clone(), arg.source_range));
|
||||
}
|
||||
fn_args.push(arg);
|
||||
}
|
||||
let tag_declarator_args = tag_declarator_args; // remove mutability
|
||||
|
||||
match ctx.stdlib.get_either(fn_name) {
|
||||
FunctionKind::Core(func) => {
|
||||
// Attempt to call the function.
|
||||
let args = crate::std::Args::new(fn_args, self.into(), ctx.clone());
|
||||
let mut result = func.std_lib_fn()(exec_state, args).await?;
|
||||
update_memory_for_tags_of_geometry(&mut result, &tag_declarator_args, exec_state)?;
|
||||
update_memory_for_tags_of_geometry(&mut result, exec_state)?;
|
||||
Ok(result)
|
||||
}
|
||||
FunctionKind::UserDefined => {
|
||||
@ -501,24 +491,7 @@ impl Node<CallExpression> {
|
||||
}
|
||||
}
|
||||
|
||||
/// `tag_declarator_args` should only contain tag declarator literals, which
|
||||
/// will be defined as local variables. Non-literals that evaluate to tag
|
||||
/// declarators should not be defined.
|
||||
fn update_memory_for_tags_of_geometry(
|
||||
result: &mut KclValue,
|
||||
tag_declarator_args: &[(TagDeclarator, SourceRange)],
|
||||
exec_state: &mut ExecState,
|
||||
) -> Result<(), KclError> {
|
||||
// Define all the tags in the memory.
|
||||
for (tag_declarator, arg_sr) in tag_declarator_args {
|
||||
let tag = TagIdentifier {
|
||||
value: tag_declarator.name.clone(),
|
||||
info: None,
|
||||
meta: vec![Metadata { source_range: *arg_sr }],
|
||||
};
|
||||
|
||||
exec_state.memory.add_tag(&tag.value, tag.clone(), *arg_sr)?;
|
||||
}
|
||||
fn update_memory_for_tags_of_geometry(result: &mut KclValue, exec_state: &mut ExecState) -> Result<(), KclError> {
|
||||
// If the return result is a sketch or solid, we want to update the
|
||||
// memory for the tags of the group.
|
||||
// TODO: This could probably be done in a better way, but as of now this was my only idea
|
||||
@ -526,7 +499,7 @@ fn update_memory_for_tags_of_geometry(
|
||||
match result {
|
||||
KclValue::Sketch { value: ref mut sketch } => {
|
||||
for (_, tag) in sketch.tags.iter() {
|
||||
exec_state.memory.update_tag_if_defined(&tag.value, tag.clone());
|
||||
exec_state.memory.update_tag(&tag.value, tag.clone())?;
|
||||
}
|
||||
}
|
||||
KclValue::Solid(ref mut solid) => {
|
||||
@ -564,7 +537,7 @@ fn update_memory_for_tags_of_geometry(
|
||||
info.sketch = solid.id;
|
||||
t.info = Some(info);
|
||||
|
||||
exec_state.memory.update_tag_if_defined(&tag.name, t.clone());
|
||||
exec_state.memory.update_tag(&tag.name, t.clone())?;
|
||||
|
||||
// update the sketch tags.
|
||||
solid.sketch.tags.insert(tag.name.clone(), t);
|
||||
@ -585,6 +558,22 @@ fn update_memory_for_tags_of_geometry(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl Node<TagDeclarator> {
|
||||
pub async fn execute(&self, exec_state: &mut ExecState) -> Result<KclValue, KclError> {
|
||||
let memory_item = KclValue::TagIdentifier(Box::new(TagIdentifier {
|
||||
value: self.name.clone(),
|
||||
info: None,
|
||||
meta: vec![Metadata {
|
||||
source_range: self.into(),
|
||||
}],
|
||||
}));
|
||||
|
||||
exec_state.memory.add(&self.name, memory_item.clone(), self.into())?;
|
||||
|
||||
Ok(self.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl Node<ArrayExpression> {
|
||||
#[async_recursion]
|
||||
pub async fn execute(&self, exec_state: &mut ExecState, ctx: &ExecutorContext) -> Result<KclValue, KclError> {
|
||||
|
||||
@ -124,16 +124,10 @@ impl ProgramMemory {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn add_tag(&mut self, tag: &str, value: TagIdentifier, source_range: SourceRange) -> Result<(), KclError> {
|
||||
self.add(tag, KclValue::TagIdentifier(Box::new(value)), source_range)
|
||||
}
|
||||
|
||||
pub fn update_tag_if_defined(&mut self, tag: &str, value: TagIdentifier) {
|
||||
if !self.environments[self.current_env.index()].contains_key(tag) {
|
||||
// Do nothing if the tag isn't defined.
|
||||
return;
|
||||
}
|
||||
pub fn update_tag(&mut self, tag: &str, value: TagIdentifier) -> Result<(), KclError> {
|
||||
self.environments[self.current_env.index()].insert(tag.to_string(), KclValue::TagIdentifier(Box::new(value)));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get a value from the program memory.
|
||||
@ -850,7 +844,7 @@ impl GetTangentialInfoFromPathsResult {
|
||||
|
||||
impl Sketch {
|
||||
pub(crate) fn add_tag(&mut self, tag: NodeRef<'_, TagDeclarator>, current_path: &Path) {
|
||||
let mut tag_identifier = TagIdentifier::from(tag);
|
||||
let mut tag_identifier: TagIdentifier = tag.into();
|
||||
let base = current_path.get_base();
|
||||
tag_identifier.info = Some(TagEngineInfo {
|
||||
id: base.geo_meta.id,
|
||||
@ -2136,7 +2130,7 @@ impl ExecutorContext {
|
||||
let item = match init {
|
||||
Expr::None(none) => KclValue::from(none),
|
||||
Expr::Literal(literal) => KclValue::from(literal),
|
||||
Expr::TagDeclarator(tag) => KclValue::from(tag),
|
||||
Expr::TagDeclarator(tag) => tag.execute(exec_state).await?,
|
||||
Expr::Identifier(identifier) => {
|
||||
let value = exec_state.memory.get(&identifier.name, identifier.into())?;
|
||||
value.clone()
|
||||
@ -3054,10 +3048,8 @@ let notTagDeclarator = !myTagDeclarator";
|
||||
);
|
||||
|
||||
let code9 = "
|
||||
sk = startSketchOn('XY')
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([5, 0], %, $myTag)
|
||||
notTagIdentifier = !myTag";
|
||||
let myTagDeclarator = $myTag
|
||||
let notTagIdentifier = !myTag";
|
||||
let tag_identifier_err = parse_execute(code9).await.unwrap_err().downcast::<KclError>().unwrap();
|
||||
// These are currently printed out as JSON objects, so we don't want to
|
||||
// check the full error.
|
||||
|
||||
@ -1502,48 +1502,6 @@ mod kw_fn {
|
||||
super::execute(TEST_NAME, true).await
|
||||
}
|
||||
}
|
||||
mod tag_can_be_proxied_through_parameter {
|
||||
const TEST_NAME: &str = "tag_can_be_proxied_through_parameter";
|
||||
|
||||
/// Test parsing KCL.
|
||||
#[test]
|
||||
fn parse() {
|
||||
super::parse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||
#[test]
|
||||
fn unparse() {
|
||||
super::unparse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that KCL is executed correctly.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_execute() {
|
||||
super::execute(TEST_NAME, false).await
|
||||
}
|
||||
}
|
||||
mod tag_proxied_through_function_does_not_define_var {
|
||||
const TEST_NAME: &str = "tag_proxied_through_function_does_not_define_var";
|
||||
|
||||
/// Test parsing KCL.
|
||||
#[test]
|
||||
fn parse() {
|
||||
super::parse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||
#[test]
|
||||
fn unparse() {
|
||||
super::unparse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that KCL is executed correctly.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_execute() {
|
||||
super::execute(TEST_NAME, false).await
|
||||
}
|
||||
}
|
||||
mod kw_fn_too_few_args {
|
||||
const TEST_NAME: &str = "kw_fn_too_few_args";
|
||||
|
||||
|
||||
@ -87,6 +87,72 @@ snapshot_kind: text
|
||||
}
|
||||
]
|
||||
},
|
||||
"arc_tag": {
|
||||
"type": "TagIdentifier",
|
||||
"type": "TagIdentifier",
|
||||
"value": "arc_tag",
|
||||
"info": {
|
||||
"type": "TagEngineInfo",
|
||||
"id": "[uuid]",
|
||||
"sketch": "[uuid]",
|
||||
"path": {
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": [
|
||||
527,
|
||||
549,
|
||||
0
|
||||
]
|
||||
},
|
||||
"ccw": true,
|
||||
"center": [
|
||||
200.0,
|
||||
100.0
|
||||
],
|
||||
"from": [
|
||||
280.0,
|
||||
100.0
|
||||
],
|
||||
"radius": 80.0,
|
||||
"tag": {
|
||||
"end": 548,
|
||||
"start": 540,
|
||||
"type": "TagDeclarator",
|
||||
"value": "arc_tag"
|
||||
},
|
||||
"to": [
|
||||
280.0,
|
||||
99.99999999999999
|
||||
],
|
||||
"type": "Arc"
|
||||
},
|
||||
"surface": {
|
||||
"faceId": "[uuid]",
|
||||
"id": "[uuid]",
|
||||
"sourceRange": [
|
||||
527,
|
||||
549,
|
||||
0
|
||||
],
|
||||
"tag": {
|
||||
"end": 548,
|
||||
"start": 540,
|
||||
"type": "TagDeclarator",
|
||||
"value": "arc_tag"
|
||||
},
|
||||
"type": "extrudeArc"
|
||||
}
|
||||
},
|
||||
"__meta": [
|
||||
{
|
||||
"sourceRange": [
|
||||
540,
|
||||
548,
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"b": {
|
||||
"type": "TagIdentifier",
|
||||
"type": "TagIdentifier",
|
||||
|
||||
@ -1,586 +0,0 @@
|
||||
---
|
||||
source: kcl/src/simulation_tests.rs
|
||||
description: Result of parsing tag_can_be_proxied_through_parameter.kcl
|
||||
snapshot_kind: text
|
||||
---
|
||||
{
|
||||
"Ok": {
|
||||
"body": [
|
||||
{
|
||||
"declaration": {
|
||||
"end": 118,
|
||||
"id": {
|
||||
"end": 47,
|
||||
"name": "myCircle",
|
||||
"start": 39,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"body": {
|
||||
"body": [
|
||||
{
|
||||
"argument": {
|
||||
"arguments": [
|
||||
{
|
||||
"end": 106,
|
||||
"properties": [
|
||||
{
|
||||
"end": 87,
|
||||
"key": {
|
||||
"end": 83,
|
||||
"name": "radius",
|
||||
"start": 77,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 77,
|
||||
"type": "ObjectProperty",
|
||||
"value": {
|
||||
"end": 87,
|
||||
"raw": "4",
|
||||
"start": 86,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 4.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"end": 104,
|
||||
"key": {
|
||||
"end": 95,
|
||||
"name": "center",
|
||||
"start": 89,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 89,
|
||||
"type": "ObjectProperty",
|
||||
"value": {
|
||||
"elements": [
|
||||
{
|
||||
"end": 100,
|
||||
"raw": "0",
|
||||
"start": 99,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 0.0
|
||||
},
|
||||
{
|
||||
"end": 103,
|
||||
"raw": "0",
|
||||
"start": 102,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 0.0
|
||||
}
|
||||
],
|
||||
"end": 104,
|
||||
"start": 98,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"start": 75,
|
||||
"type": "ObjectExpression",
|
||||
"type": "ObjectExpression"
|
||||
},
|
||||
{
|
||||
"end": 110,
|
||||
"name": "sk",
|
||||
"start": 108,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
{
|
||||
"end": 115,
|
||||
"name": "tag",
|
||||
"start": 112,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 74,
|
||||
"name": "circle",
|
||||
"start": 68,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 116,
|
||||
"start": 68,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
},
|
||||
"end": 116,
|
||||
"start": 61,
|
||||
"type": "ReturnStatement",
|
||||
"type": "ReturnStatement"
|
||||
}
|
||||
],
|
||||
"end": 118,
|
||||
"start": 57
|
||||
},
|
||||
"end": 118,
|
||||
"params": [
|
||||
{
|
||||
"type": "Parameter",
|
||||
"identifier": {
|
||||
"end": 50,
|
||||
"name": "sk",
|
||||
"start": 48,
|
||||
"type": "Identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Parameter",
|
||||
"identifier": {
|
||||
"end": 55,
|
||||
"name": "tag",
|
||||
"start": 52,
|
||||
"type": "Identifier"
|
||||
}
|
||||
}
|
||||
],
|
||||
"start": 47,
|
||||
"type": "FunctionExpression",
|
||||
"type": "FunctionExpression"
|
||||
},
|
||||
"start": 39,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 118,
|
||||
"kind": "fn",
|
||||
"start": 36,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
},
|
||||
{
|
||||
"declaration": {
|
||||
"end": 223,
|
||||
"id": {
|
||||
"end": 122,
|
||||
"name": "c1",
|
||||
"start": 120,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"body": [
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"end": 143,
|
||||
"raw": "'XY'",
|
||||
"start": 139,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": "XY"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 138,
|
||||
"name": "startSketchOn",
|
||||
"start": 125,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 144,
|
||||
"start": 125,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"elements": [
|
||||
{
|
||||
"end": 167,
|
||||
"raw": "0",
|
||||
"start": 166,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 0.0
|
||||
},
|
||||
{
|
||||
"end": 170,
|
||||
"raw": "0",
|
||||
"start": 169,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 0.0
|
||||
}
|
||||
],
|
||||
"end": 171,
|
||||
"start": 165,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
{
|
||||
"end": 174,
|
||||
"start": 173,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 164,
|
||||
"name": "startProfileAt",
|
||||
"start": 150,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 175,
|
||||
"start": 150,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"end": 191,
|
||||
"start": 190,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
},
|
||||
{
|
||||
"end": 198,
|
||||
"start": 193,
|
||||
"type": "TagDeclarator",
|
||||
"type": "TagDeclarator",
|
||||
"value": "mine"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 189,
|
||||
"name": "myCircle",
|
||||
"start": 181,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 199,
|
||||
"start": 181,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
}
|
||||
],
|
||||
"end": 223,
|
||||
"nonCodeMeta": {
|
||||
"nonCodeNodes": {
|
||||
"2": [
|
||||
{
|
||||
"end": 223,
|
||||
"start": 199,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "blockComment",
|
||||
"value": "The tag can be used.",
|
||||
"style": "line"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"startNodes": []
|
||||
},
|
||||
"start": 125,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
},
|
||||
"start": 120,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 223,
|
||||
"kind": "const",
|
||||
"start": 120,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
},
|
||||
{
|
||||
"declaration": {
|
||||
"end": 257,
|
||||
"id": {
|
||||
"end": 228,
|
||||
"name": "ang1",
|
||||
"start": 224,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"arguments": [
|
||||
{
|
||||
"computed": false,
|
||||
"end": 256,
|
||||
"object": {
|
||||
"computed": false,
|
||||
"end": 251,
|
||||
"object": {
|
||||
"end": 246,
|
||||
"name": "c1",
|
||||
"start": 244,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"property": {
|
||||
"end": 251,
|
||||
"name": "tags",
|
||||
"start": 247,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 244,
|
||||
"type": "MemberExpression",
|
||||
"type": "MemberExpression"
|
||||
},
|
||||
"property": {
|
||||
"end": 256,
|
||||
"name": "mine",
|
||||
"start": 252,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 244,
|
||||
"type": "MemberExpression",
|
||||
"type": "MemberExpression"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 243,
|
||||
"name": "tangentToEnd",
|
||||
"start": 231,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 257,
|
||||
"start": 231,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
},
|
||||
"start": 224,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 257,
|
||||
"kind": "const",
|
||||
"start": 224,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
},
|
||||
{
|
||||
"declaration": {
|
||||
"end": 384,
|
||||
"id": {
|
||||
"end": 307,
|
||||
"name": "c2",
|
||||
"start": 305,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"body": [
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"end": 328,
|
||||
"raw": "'XY'",
|
||||
"start": 324,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": "XY"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 323,
|
||||
"name": "startSketchOn",
|
||||
"start": 310,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 329,
|
||||
"start": 310,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"elements": [
|
||||
{
|
||||
"end": 352,
|
||||
"raw": "0",
|
||||
"start": 351,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 0.0
|
||||
},
|
||||
{
|
||||
"end": 355,
|
||||
"raw": "0",
|
||||
"start": 354,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 0.0
|
||||
}
|
||||
],
|
||||
"end": 356,
|
||||
"start": 350,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
{
|
||||
"end": 359,
|
||||
"start": 358,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 349,
|
||||
"name": "startProfileAt",
|
||||
"start": 335,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 360,
|
||||
"start": 335,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"end": 376,
|
||||
"start": 375,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
},
|
||||
{
|
||||
"end": 383,
|
||||
"start": 378,
|
||||
"type": "TagDeclarator",
|
||||
"type": "TagDeclarator",
|
||||
"value": "mine"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 374,
|
||||
"name": "myCircle",
|
||||
"start": 366,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 384,
|
||||
"start": 366,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
}
|
||||
],
|
||||
"end": 384,
|
||||
"start": 310,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
},
|
||||
"start": 305,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 384,
|
||||
"kind": "const",
|
||||
"start": 305,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
},
|
||||
{
|
||||
"declaration": {
|
||||
"end": 418,
|
||||
"id": {
|
||||
"end": 389,
|
||||
"name": "ang2",
|
||||
"start": 385,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"arguments": [
|
||||
{
|
||||
"computed": false,
|
||||
"end": 417,
|
||||
"object": {
|
||||
"computed": false,
|
||||
"end": 412,
|
||||
"object": {
|
||||
"end": 407,
|
||||
"name": "c2",
|
||||
"start": 405,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"property": {
|
||||
"end": 412,
|
||||
"name": "tags",
|
||||
"start": 408,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 405,
|
||||
"type": "MemberExpression",
|
||||
"type": "MemberExpression"
|
||||
},
|
||||
"property": {
|
||||
"end": 417,
|
||||
"name": "mine",
|
||||
"start": 413,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 405,
|
||||
"type": "MemberExpression",
|
||||
"type": "MemberExpression"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 404,
|
||||
"name": "tangentToEnd",
|
||||
"start": 392,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 418,
|
||||
"start": 392,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
},
|
||||
"start": 385,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 418,
|
||||
"kind": "const",
|
||||
"start": 385,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
}
|
||||
],
|
||||
"end": 419,
|
||||
"nonCodeMeta": {
|
||||
"nonCodeNodes": {
|
||||
"0": [
|
||||
{
|
||||
"end": 120,
|
||||
"start": 118,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "newLine"
|
||||
}
|
||||
}
|
||||
],
|
||||
"2": [
|
||||
{
|
||||
"end": 304,
|
||||
"start": 257,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "newLineBlockComment",
|
||||
"value": "The same tag declarator can be used again.",
|
||||
"style": "line"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"startNodes": [
|
||||
{
|
||||
"end": 35,
|
||||
"start": 0,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "blockComment",
|
||||
"value": "A function with a tag parameter.",
|
||||
"style": "line"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"start": 0
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
// A function with a tag parameter.
|
||||
fn myCircle(sk, tag) {
|
||||
return circle({ radius = 4, center = [0, 0] }, sk, tag)
|
||||
}
|
||||
|
||||
c1 = startSketchOn('XY')
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> myCircle(%, $mine)
|
||||
// The tag can be used.
|
||||
ang1 = tangentToEnd(c1.tags.mine)
|
||||
|
||||
// The same tag declarator can be used again.
|
||||
c2 = startSketchOn('XY')
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> myCircle(%, $mine)
|
||||
ang2 = tangentToEnd(c2.tags.mine)
|
||||
@ -1,524 +0,0 @@
|
||||
---
|
||||
source: kcl/src/simulation_tests.rs
|
||||
description: Program memory after executing tag_can_be_proxied_through_parameter.kcl
|
||||
snapshot_kind: text
|
||||
---
|
||||
{
|
||||
"environments": [
|
||||
{
|
||||
"bindings": {
|
||||
"HALF_TURN": {
|
||||
"type": "Number",
|
||||
"value": 180.0,
|
||||
"__meta": []
|
||||
},
|
||||
"QUARTER_TURN": {
|
||||
"type": "Number",
|
||||
"value": 90.0,
|
||||
"__meta": []
|
||||
},
|
||||
"THREE_QUARTER_TURN": {
|
||||
"type": "Number",
|
||||
"value": 270.0,
|
||||
"__meta": []
|
||||
},
|
||||
"ZERO": {
|
||||
"type": "Number",
|
||||
"value": 0.0,
|
||||
"__meta": []
|
||||
},
|
||||
"ang1": {
|
||||
"type": "Number",
|
||||
"value": 90.0,
|
||||
"__meta": [
|
||||
{
|
||||
"sourceRange": [
|
||||
231,
|
||||
257,
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"ang2": {
|
||||
"type": "Number",
|
||||
"value": 90.0,
|
||||
"__meta": [
|
||||
{
|
||||
"sourceRange": [
|
||||
392,
|
||||
418,
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"c1": {
|
||||
"type": "Sketch",
|
||||
"value": {
|
||||
"type": "Sketch",
|
||||
"id": "[uuid]",
|
||||
"paths": [
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": [
|
||||
68,
|
||||
116,
|
||||
0
|
||||
]
|
||||
},
|
||||
"ccw": true,
|
||||
"center": [
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"from": [
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"radius": 4.0,
|
||||
"tag": {
|
||||
"end": 198,
|
||||
"start": 193,
|
||||
"type": "TagDeclarator",
|
||||
"value": "mine"
|
||||
},
|
||||
"to": [
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"type": "Circle"
|
||||
}
|
||||
],
|
||||
"on": {
|
||||
"type": "plane",
|
||||
"id": "[uuid]",
|
||||
"value": "XY",
|
||||
"origin": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"xAxis": {
|
||||
"x": 1.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"yAxis": {
|
||||
"x": 0.0,
|
||||
"y": 1.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"zAxis": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 1.0
|
||||
},
|
||||
"__meta": []
|
||||
},
|
||||
"start": {
|
||||
"from": [
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"to": [
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"tag": null,
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": [
|
||||
68,
|
||||
116,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
"tags": {
|
||||
"mine": {
|
||||
"type": "TagIdentifier",
|
||||
"value": "mine",
|
||||
"info": {
|
||||
"type": "TagEngineInfo",
|
||||
"id": "[uuid]",
|
||||
"sketch": "[uuid]",
|
||||
"path": {
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": [
|
||||
68,
|
||||
116,
|
||||
0
|
||||
]
|
||||
},
|
||||
"ccw": true,
|
||||
"center": [
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"from": [
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"radius": 4.0,
|
||||
"tag": {
|
||||
"end": 198,
|
||||
"start": 193,
|
||||
"type": "TagDeclarator",
|
||||
"value": "mine"
|
||||
},
|
||||
"to": [
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"type": "Circle"
|
||||
},
|
||||
"surface": null
|
||||
},
|
||||
"__meta": [
|
||||
{
|
||||
"sourceRange": [
|
||||
193,
|
||||
198,
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"__meta": [
|
||||
{
|
||||
"sourceRange": [
|
||||
68,
|
||||
116,
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"c2": {
|
||||
"type": "Sketch",
|
||||
"value": {
|
||||
"type": "Sketch",
|
||||
"id": "[uuid]",
|
||||
"paths": [
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": [
|
||||
68,
|
||||
116,
|
||||
0
|
||||
]
|
||||
},
|
||||
"ccw": true,
|
||||
"center": [
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"from": [
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"radius": 4.0,
|
||||
"tag": {
|
||||
"end": 383,
|
||||
"start": 378,
|
||||
"type": "TagDeclarator",
|
||||
"value": "mine"
|
||||
},
|
||||
"to": [
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"type": "Circle"
|
||||
}
|
||||
],
|
||||
"on": {
|
||||
"type": "plane",
|
||||
"id": "[uuid]",
|
||||
"value": "XY",
|
||||
"origin": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"xAxis": {
|
||||
"x": 1.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"yAxis": {
|
||||
"x": 0.0,
|
||||
"y": 1.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"zAxis": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 1.0
|
||||
},
|
||||
"__meta": []
|
||||
},
|
||||
"start": {
|
||||
"from": [
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"to": [
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"tag": null,
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": [
|
||||
68,
|
||||
116,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
"tags": {
|
||||
"mine": {
|
||||
"type": "TagIdentifier",
|
||||
"value": "mine",
|
||||
"info": {
|
||||
"type": "TagEngineInfo",
|
||||
"id": "[uuid]",
|
||||
"sketch": "[uuid]",
|
||||
"path": {
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": [
|
||||
68,
|
||||
116,
|
||||
0
|
||||
]
|
||||
},
|
||||
"ccw": true,
|
||||
"center": [
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"from": [
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"radius": 4.0,
|
||||
"tag": {
|
||||
"end": 383,
|
||||
"start": 378,
|
||||
"type": "TagDeclarator",
|
||||
"value": "mine"
|
||||
},
|
||||
"to": [
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"type": "Circle"
|
||||
},
|
||||
"surface": null
|
||||
},
|
||||
"__meta": [
|
||||
{
|
||||
"sourceRange": [
|
||||
378,
|
||||
383,
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"__meta": [
|
||||
{
|
||||
"sourceRange": [
|
||||
68,
|
||||
116,
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"myCircle": {
|
||||
"type": "Function",
|
||||
"expression": {
|
||||
"body": {
|
||||
"body": [
|
||||
{
|
||||
"argument": {
|
||||
"arguments": [
|
||||
{
|
||||
"end": 106,
|
||||
"properties": [
|
||||
{
|
||||
"end": 87,
|
||||
"key": {
|
||||
"end": 83,
|
||||
"name": "radius",
|
||||
"start": 77,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 77,
|
||||
"type": "ObjectProperty",
|
||||
"value": {
|
||||
"end": 87,
|
||||
"raw": "4",
|
||||
"start": 86,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 4.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"end": 104,
|
||||
"key": {
|
||||
"end": 95,
|
||||
"name": "center",
|
||||
"start": 89,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 89,
|
||||
"type": "ObjectProperty",
|
||||
"value": {
|
||||
"elements": [
|
||||
{
|
||||
"end": 100,
|
||||
"raw": "0",
|
||||
"start": 99,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 0.0
|
||||
},
|
||||
{
|
||||
"end": 103,
|
||||
"raw": "0",
|
||||
"start": 102,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 0.0
|
||||
}
|
||||
],
|
||||
"end": 104,
|
||||
"start": 98,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"start": 75,
|
||||
"type": "ObjectExpression",
|
||||
"type": "ObjectExpression"
|
||||
},
|
||||
{
|
||||
"end": 110,
|
||||
"name": "sk",
|
||||
"start": 108,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
{
|
||||
"end": 115,
|
||||
"name": "tag",
|
||||
"start": 112,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 74,
|
||||
"name": "circle",
|
||||
"start": 68,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 116,
|
||||
"start": 68,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
},
|
||||
"end": 116,
|
||||
"start": 61,
|
||||
"type": "ReturnStatement",
|
||||
"type": "ReturnStatement"
|
||||
}
|
||||
],
|
||||
"end": 118,
|
||||
"start": 57
|
||||
},
|
||||
"end": 118,
|
||||
"params": [
|
||||
{
|
||||
"type": "Parameter",
|
||||
"identifier": {
|
||||
"end": 50,
|
||||
"name": "sk",
|
||||
"start": 48,
|
||||
"type": "Identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Parameter",
|
||||
"identifier": {
|
||||
"end": 55,
|
||||
"name": "tag",
|
||||
"start": 52,
|
||||
"type": "Identifier"
|
||||
}
|
||||
}
|
||||
],
|
||||
"start": 47,
|
||||
"type": "FunctionExpression"
|
||||
},
|
||||
"memory": {
|
||||
"environments": [
|
||||
{
|
||||
"bindings": {
|
||||
"HALF_TURN": {
|
||||
"type": "Number",
|
||||
"value": 180.0,
|
||||
"__meta": []
|
||||
},
|
||||
"QUARTER_TURN": {
|
||||
"type": "Number",
|
||||
"value": 90.0,
|
||||
"__meta": []
|
||||
},
|
||||
"THREE_QUARTER_TURN": {
|
||||
"type": "Number",
|
||||
"value": 270.0,
|
||||
"__meta": []
|
||||
},
|
||||
"ZERO": {
|
||||
"type": "Number",
|
||||
"value": 0.0,
|
||||
"__meta": []
|
||||
}
|
||||
},
|
||||
"parent": null
|
||||
}
|
||||
],
|
||||
"currentEnv": 0,
|
||||
"return": null
|
||||
},
|
||||
"__meta": [
|
||||
{
|
||||
"sourceRange": [
|
||||
47,
|
||||
118,
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"parent": null
|
||||
}
|
||||
],
|
||||
"currentEnv": 0,
|
||||
"return": null
|
||||
}
|
||||
@ -1,400 +0,0 @@
|
||||
---
|
||||
source: kcl/src/simulation_tests.rs
|
||||
description: Result of parsing tag_proxied_through_function_does_not_define_var.kcl
|
||||
snapshot_kind: text
|
||||
---
|
||||
{
|
||||
"Ok": {
|
||||
"body": [
|
||||
{
|
||||
"declaration": {
|
||||
"end": 193,
|
||||
"id": {
|
||||
"end": 47,
|
||||
"name": "myCircle",
|
||||
"start": 39,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"body": {
|
||||
"body": [
|
||||
{
|
||||
"declaration": {
|
||||
"end": 113,
|
||||
"id": {
|
||||
"end": 62,
|
||||
"name": "c",
|
||||
"start": 61,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"arguments": [
|
||||
{
|
||||
"end": 103,
|
||||
"properties": [
|
||||
{
|
||||
"end": 84,
|
||||
"key": {
|
||||
"end": 80,
|
||||
"name": "radius",
|
||||
"start": 74,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 74,
|
||||
"type": "ObjectProperty",
|
||||
"value": {
|
||||
"end": 84,
|
||||
"raw": "4",
|
||||
"start": 83,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 4.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"end": 101,
|
||||
"key": {
|
||||
"end": 92,
|
||||
"name": "center",
|
||||
"start": 86,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 86,
|
||||
"type": "ObjectProperty",
|
||||
"value": {
|
||||
"elements": [
|
||||
{
|
||||
"end": 97,
|
||||
"raw": "0",
|
||||
"start": 96,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 0.0
|
||||
},
|
||||
{
|
||||
"end": 100,
|
||||
"raw": "0",
|
||||
"start": 99,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 0.0
|
||||
}
|
||||
],
|
||||
"end": 101,
|
||||
"start": 95,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"start": 72,
|
||||
"type": "ObjectExpression",
|
||||
"type": "ObjectExpression"
|
||||
},
|
||||
{
|
||||
"end": 107,
|
||||
"name": "sk",
|
||||
"start": 105,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
{
|
||||
"end": 112,
|
||||
"name": "tag",
|
||||
"start": 109,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 71,
|
||||
"name": "circle",
|
||||
"start": 65,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 113,
|
||||
"start": 65,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
},
|
||||
"start": 61,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 113,
|
||||
"kind": "const",
|
||||
"start": 61,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
},
|
||||
{
|
||||
"declaration": {
|
||||
"end": 173,
|
||||
"id": {
|
||||
"end": 152,
|
||||
"name": "ang",
|
||||
"start": 149,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"arguments": [
|
||||
{
|
||||
"end": 172,
|
||||
"name": "mine",
|
||||
"start": 168,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 167,
|
||||
"name": "tangentToEnd",
|
||||
"start": 155,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 173,
|
||||
"start": 155,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
},
|
||||
"start": 149,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 173,
|
||||
"kind": "const",
|
||||
"start": 149,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
},
|
||||
{
|
||||
"argument": {
|
||||
"elements": [
|
||||
{
|
||||
"end": 185,
|
||||
"name": "c",
|
||||
"start": 184,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
{
|
||||
"end": 190,
|
||||
"name": "ang",
|
||||
"start": 187,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
}
|
||||
],
|
||||
"end": 191,
|
||||
"start": 183,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
"end": 191,
|
||||
"start": 176,
|
||||
"type": "ReturnStatement",
|
||||
"type": "ReturnStatement"
|
||||
}
|
||||
],
|
||||
"end": 193,
|
||||
"nonCodeMeta": {
|
||||
"nonCodeNodes": {
|
||||
"0": [
|
||||
{
|
||||
"end": 146,
|
||||
"start": 115,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "blockComment",
|
||||
"value": "This should not be allowed.",
|
||||
"style": "line"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"startNodes": []
|
||||
},
|
||||
"start": 57
|
||||
},
|
||||
"end": 193,
|
||||
"params": [
|
||||
{
|
||||
"type": "Parameter",
|
||||
"identifier": {
|
||||
"end": 50,
|
||||
"name": "sk",
|
||||
"start": 48,
|
||||
"type": "Identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Parameter",
|
||||
"identifier": {
|
||||
"end": 55,
|
||||
"name": "tag",
|
||||
"start": 52,
|
||||
"type": "Identifier"
|
||||
}
|
||||
}
|
||||
],
|
||||
"start": 47,
|
||||
"type": "FunctionExpression",
|
||||
"type": "FunctionExpression"
|
||||
},
|
||||
"start": 39,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 193,
|
||||
"kind": "fn",
|
||||
"start": 36,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
},
|
||||
{
|
||||
"declaration": {
|
||||
"end": 274,
|
||||
"id": {
|
||||
"end": 197,
|
||||
"name": "c1",
|
||||
"start": 195,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"body": [
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"end": 218,
|
||||
"raw": "'XY'",
|
||||
"start": 214,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": "XY"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 213,
|
||||
"name": "startSketchOn",
|
||||
"start": 200,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 219,
|
||||
"start": 200,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"elements": [
|
||||
{
|
||||
"end": 242,
|
||||
"raw": "0",
|
||||
"start": 241,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 0.0
|
||||
},
|
||||
{
|
||||
"end": 245,
|
||||
"raw": "0",
|
||||
"start": 244,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": 0.0
|
||||
}
|
||||
],
|
||||
"end": 246,
|
||||
"start": 240,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
{
|
||||
"end": 249,
|
||||
"start": 248,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 239,
|
||||
"name": "startProfileAt",
|
||||
"start": 225,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 250,
|
||||
"start": 225,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"end": 266,
|
||||
"start": 265,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
},
|
||||
{
|
||||
"end": 273,
|
||||
"start": 268,
|
||||
"type": "TagDeclarator",
|
||||
"type": "TagDeclarator",
|
||||
"value": "mine"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 264,
|
||||
"name": "myCircle",
|
||||
"start": 256,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 274,
|
||||
"start": 256,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
}
|
||||
],
|
||||
"end": 274,
|
||||
"start": 200,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
},
|
||||
"start": 195,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 274,
|
||||
"kind": "const",
|
||||
"start": 195,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
}
|
||||
],
|
||||
"end": 275,
|
||||
"nonCodeMeta": {
|
||||
"nonCodeNodes": {
|
||||
"0": [
|
||||
{
|
||||
"end": 195,
|
||||
"start": 193,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "newLine"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"startNodes": [
|
||||
{
|
||||
"end": 35,
|
||||
"start": 0,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "blockComment",
|
||||
"value": "A function with a tag parameter.",
|
||||
"style": "line"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"start": 0
|
||||
}
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
---
|
||||
source: kcl/src/simulation_tests.rs
|
||||
description: Error from executing tag_proxied_through_function_does_not_define_var.kcl
|
||||
snapshot_kind: text
|
||||
---
|
||||
KCL UndefinedValue error
|
||||
|
||||
× undefined value: memory item key `mine` is not defined
|
||||
╭─[5:22]
|
||||
4 │ // This should not be allowed.
|
||||
5 │ ang = tangentToEnd(mine)
|
||||
· ────
|
||||
6 │ return [c, ang]
|
||||
7 │ }
|
||||
8 │
|
||||
9 │ c1 = startSketchOn('XY')
|
||||
10 │ |> startProfileAt([0, 0], %)
|
||||
11 │ |> myCircle(%, $mine)
|
||||
· ──────────────────
|
||||
╰────
|
||||
@ -1,11 +0,0 @@
|
||||
// A function with a tag parameter.
|
||||
fn myCircle(sk, tag) {
|
||||
c = circle({ radius = 4, center = [0, 0] }, sk, tag)
|
||||
// This should not be allowed.
|
||||
ang = tangentToEnd(mine)
|
||||
return [c, ang]
|
||||
}
|
||||
|
||||
c1 = startSketchOn('XY')
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> myCircle(%, $mine)
|
||||
Reference in New Issue
Block a user