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:
Jonathan Tran
2025-05-11 23:57:31 -04:00
committed by GitHub
parent 86e8bcfe0b
commit bbe89f56a7
53 changed files with 2942 additions and 1839 deletions

View File

@ -0,0 +1,32 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Artifact commands any_type.kcl
---
[
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "edge_lines_visible",
"hidden": false
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
}
]

View File

@ -0,0 +1,6 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Artifact graph flowchart any_type.kcl
extension: md
snapshot_kind: binary
---

View File

@ -0,0 +1,3 @@
```mermaid
flowchart LR
```

View File

@ -0,0 +1,921 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Result of parsing any_type.kcl
---
{
"Ok": {
"body": [
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "id",
"start": 0,
"type": "Identifier"
},
"init": {
"body": {
"body": [
{
"argument": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "x",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "ReturnStatement",
"type": "ReturnStatement"
}
],
"commentStart": 0,
"end": 0,
"start": 0
},
"commentStart": 0,
"end": 0,
"params": [
{
"type": "Parameter",
"identifier": {
"commentStart": 0,
"end": 0,
"name": "x",
"start": 0,
"type": "Identifier"
},
"labeled": false
}
],
"start": 0,
"type": "FunctionExpression",
"type": "FunctionExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "fn",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "singleton",
"start": 0,
"type": "Identifier"
},
"init": {
"body": {
"body": [
{
"argument": {
"commentStart": 0,
"elements": [
{
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "x",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "ReturnStatement",
"type": "ReturnStatement"
}
],
"commentStart": 0,
"end": 0,
"start": 0
},
"commentStart": 0,
"end": 0,
"params": [
{
"type": "Parameter",
"identifier": {
"commentStart": 0,
"end": 0,
"name": "x",
"start": 0,
"type": "Identifier"
},
"labeled": false
}
],
"start": 0,
"type": "FunctionExpression",
"type": "FunctionExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "fn",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "len",
"start": 0,
"type": "Identifier"
},
"init": {
"body": {
"body": [
{
"argument": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "initial",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 0,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "f",
"start": 0,
"type": "Identifier"
},
"arg": {
"body": {
"body": [
{
"argument": {
"commentStart": 0,
"end": 0,
"left": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "accum",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"operator": "+",
"right": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "ReturnStatement",
"type": "ReturnStatement"
}
],
"commentStart": 0,
"end": 0,
"start": 0
},
"commentStart": 0,
"end": 0,
"params": [
{
"type": "Parameter",
"identifier": {
"commentStart": 0,
"end": 0,
"name": "_",
"start": 0,
"type": "Identifier"
},
"labeled": false
},
{
"type": "Parameter",
"identifier": {
"commentStart": 0,
"end": 0,
"name": "accum",
"start": 0,
"type": "Identifier"
}
}
],
"start": 0,
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "reduce",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "a",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "ReturnStatement",
"type": "ReturnStatement"
}
],
"commentStart": 0,
"end": 0,
"start": 0
},
"commentStart": 0,
"end": 0,
"params": [
{
"type": "Parameter",
"identifier": {
"commentStart": 0,
"end": 0,
"name": "a",
"start": 0,
"type": "Identifier"
},
"labeled": false
}
],
"start": 0,
"type": "FunctionExpression",
"type": "FunctionExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "fn",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "one",
"start": 0,
"type": "Identifier"
},
"init": {
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "id",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "a",
"start": 0,
"type": "Identifier"
},
"init": {
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "id",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"raw": "\"a\"",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": "a"
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "arr1",
"start": 0,
"type": "Identifier"
},
"init": {
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "singleton",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "len0",
"start": 0,
"type": "Identifier"
},
"init": {
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "len",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"elements": [],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "len1",
"start": 0,
"type": "Identifier"
},
"init": {
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "len",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"elements": [
{
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"end": 0,
"expression": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "isEqualTo",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "assert",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "one",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"commentStart": 0,
"end": 0,
"expression": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "isEqualTo",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 0,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "assert",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "len0",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"preComments": [
"// TODO: we cannot currently assert on strings.",
"// assert(a, isEqualTo = \"a\")",
"// TODO: we cannot currently assert on arrays.",
"// assert(arr1, isEqualTo = [1])"
],
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"commentStart": 0,
"end": 0,
"expression": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "isEqualTo",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "assert",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "len1",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"commentStart": 0,
"end": 0,
"nonCodeMeta": {
"nonCodeNodes": {
"0": [
{
"commentStart": 0,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"1": [
{
"commentStart": 0,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"2": [
{
"commentStart": 0,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"7": [
{
"commentStart": 0,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"10": [
{
"commentStart": 0,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"startNodes": []
},
"start": 0
}
}

View File

@ -0,0 +1,32 @@
fn id(@x: any): any {
return x
}
fn singleton(@x: any): [any; 1] {
return [x]
}
fn len(@a: [any]): number(_) {
return reduce(
a,
initial = 0,
f = fn(@_, accum) {
return accum + 1
},
)
}
one = id(1)
a = id("a")
arr1 = singleton(1)
len0 = len([])
len1 = len([1])
assert(one, isEqualTo = 1)
// TODO: we cannot currently assert on strings.
// assert(a, isEqualTo = "a")
// TODO: we cannot currently assert on arrays.
// assert(arr1, isEqualTo = [1])
assert(len0, isEqualTo = 0)
assert(len1, isEqualTo = 1)

View File

@ -0,0 +1,184 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Operations executed any_type.kcl
---
[
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": null,
"functionSourceRange": [],
"unlabeledArg": {
"value": {
"type": "Number",
"value": 1.0,
"ty": {
"type": "Default",
"len": {
"type": "Mm"
},
"angle": {
"type": "Degrees"
}
}
},
"sourceRange": []
},
"labeledArgs": {
"accum": {
"value": {
"type": "Number",
"value": 0.0,
"ty": {
"type": "Default",
"len": {
"type": "Mm"
},
"angle": {
"type": "Degrees"
}
}
},
"sourceRange": []
}
}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "id",
"functionSourceRange": [],
"unlabeledArg": {
"value": {
"type": "Number",
"value": 1.0,
"ty": {
"type": "Default",
"len": {
"type": "Mm"
},
"angle": {
"type": "Degrees"
}
}
},
"sourceRange": []
},
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "id",
"functionSourceRange": [],
"unlabeledArg": {
"value": {
"type": "String",
"value": "a"
},
"sourceRange": []
},
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "singleton",
"functionSourceRange": [],
"unlabeledArg": {
"value": {
"type": "Number",
"value": 1.0,
"ty": {
"type": "Default",
"len": {
"type": "Mm"
},
"angle": {
"type": "Degrees"
}
}
},
"sourceRange": []
},
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "len",
"functionSourceRange": [],
"unlabeledArg": {
"value": {
"type": "Array",
"value": []
},
"sourceRange": []
},
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "len",
"functionSourceRange": [],
"unlabeledArg": {
"value": {
"type": "Array",
"value": [
{
"type": "Number",
"value": 1.0,
"ty": {
"type": "Default",
"len": {
"type": "Mm"
},
"angle": {
"type": "Degrees"
}
}
}
]
},
"sourceRange": []
},
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupEnd"
},
{
"type": "GroupEnd"
},
{
"type": "GroupEnd"
},
{
"type": "GroupEnd"
},
{
"type": "GroupEnd"
}
]

View File

@ -0,0 +1,69 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Variables in memory after executing any_type.kcl
---
{
"a": {
"type": "String",
"value": "a"
},
"arr1": {
"type": "HomArray",
"value": [
{
"type": "Number",
"value": 1.0,
"ty": {
"type": "Default",
"len": {
"type": "Mm"
},
"angle": {
"type": "Degrees"
}
}
}
]
},
"id": {
"type": "Function",
"value": null
},
"len": {
"type": "Function",
"value": null
},
"len0": {
"type": "Number",
"value": 0.0,
"ty": {
"type": "Known",
"type": "Count"
}
},
"len1": {
"type": "Number",
"value": 1.0,
"ty": {
"type": "Known",
"type": "Count"
}
},
"one": {
"type": "Number",
"value": 1.0,
"ty": {
"type": "Default",
"len": {
"type": "Mm"
},
"angle": {
"type": "Degrees"
}
}
},
"singleton": {
"type": "Function",
"value": null
}
}

View File

@ -0,0 +1,35 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Result of unparsing any_type.kcl
---
fn id(@x: any): any {
return x
}
fn singleton(@x: any): [any; 1] {
return [x]
}
fn len(@a: [any]): number(_) {
return reduce(
a,
initial = 0,
f = fn(@_, accum) {
return accum + 1
},
)
}
one = id(1)
a = id("a")
arr1 = singleton(1)
len0 = len([])
len1 = len([1])
assert(one, isEqualTo = 1)
// TODO: we cannot currently assert on strings.
// assert(a, isEqualTo = "a")
// TODO: we cannot currently assert on arrays.
// assert(arr1, isEqualTo = [1])
assert(len0, isEqualTo = 0)
assert(len1, isEqualTo = 1)

View File

@ -4,7 +4,7 @@ description: Variables in memory after executing array_elem_pop.kcl
---
{
"arr": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -48,7 +48,7 @@ description: Variables in memory after executing array_elem_pop.kcl
]
},
"new_arr1": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -79,7 +79,7 @@ description: Variables in memory after executing array_elem_pop.kcl
]
},
"new_arr2": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -97,7 +97,7 @@ description: Variables in memory after executing array_elem_pop.kcl
]
},
"new_arr3": {
"type": "MixedArray",
"type": "HomArray",
"value": []
}
}

View File

@ -4,7 +4,7 @@ description: Variables in memory after executing array_elem_push.kcl
---
{
"arr": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -48,7 +48,7 @@ description: Variables in memory after executing array_elem_push.kcl
]
},
"new_arr1": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -105,7 +105,7 @@ description: Variables in memory after executing array_elem_push.kcl
]
},
"new_arr2": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -0,0 +1,32 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Artifact commands array_push_item_wrong_type.kcl
---
[
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "edge_lines_visible",
"hidden": false
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
}
]

View File

@ -0,0 +1,6 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Artifact graph flowchart array_push_item_wrong_type.kcl
extension: md
snapshot_kind: binary
---

View File

@ -0,0 +1,3 @@
```mermaid
flowchart LR
```

View File

@ -0,0 +1,269 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Result of parsing array_push_item_wrong_type.kcl
---
{
"Ok": {
"body": [
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "arr",
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 0,
"end": 0,
"expr": {
"commentStart": 0,
"elements": [
{
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"commentStart": 0,
"end": 0,
"raw": "2",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
}
],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 0,
"ty": {
"commentStart": 0,
"end": 0,
"len": "None",
"start": 0,
"ty": {
"Count": null,
"p_type": "Number",
"type": "Primitive"
},
"type": "Array"
},
"type": "AscribedExpression",
"type": "AscribedExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "arrPrime",
"start": 0,
"type": "Identifier"
},
"init": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "item",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 0,
"end": 0,
"raw": "4mm",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 4.0,
"suffix": "Mm"
}
}
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "push",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "arr",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"end": 0,
"expression": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "isEqualTo",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 0,
"end": 0,
"raw": "4mm",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 4.0,
"suffix": "Mm"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "error",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 0,
"end": 0,
"raw": "\"should have been added to the end of the array\"",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": "should have been added to the end of the array"
}
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "assert",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"computed": false,
"end": 0,
"object": {
"commentStart": 0,
"end": 0,
"name": "arrPrime",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"commentStart": 0,
"end": 0,
"raw": "2",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 0,
"type": "MemberExpression",
"type": "MemberExpression"
}
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"commentStart": 0,
"end": 0,
"start": 0
}
}

View File

@ -0,0 +1,3 @@
arr = [1, 2]: [number(_)]
arrPrime = push(arr, item = 4mm)
assert(arrPrime[2], isEqualTo = 4mm, error = "should have been added to the end of the array")

View File

@ -0,0 +1,5 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Operations executed array_push_item_wrong_type.kcl
---
[]

View File

@ -0,0 +1,57 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Variables in memory after executing array_push_item_wrong_type.kcl
---
{
"arr": {
"type": "HomArray",
"value": [
{
"type": "Number",
"value": 1.0,
"ty": {
"type": "Known",
"type": "Count"
}
},
{
"type": "Number",
"value": 2.0,
"ty": {
"type": "Known",
"type": "Count"
}
}
]
},
"arrPrime": {
"type": "HomArray",
"value": [
{
"type": "Number",
"value": 1.0,
"ty": {
"type": "Known",
"type": "Count"
}
},
{
"type": "Number",
"value": 2.0,
"ty": {
"type": "Known",
"type": "Count"
}
},
{
"type": "Number",
"value": 4.0,
"ty": {
"type": "Known",
"type": "Length",
"type": "Mm"
}
}
]
}
}

View File

@ -0,0 +1,7 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Result of unparsing array_push_item_wrong_type.kcl
---
arr = [1, 2]: [number(_)]
arrPrime = push(arr, item = 4mm)
assert(arrPrime[2], isEqualTo = 4mm, error = "should have been added to the end of the array")

View File

@ -30,7 +30,7 @@ description: Variables in memory after executing array_range_expr.kcl
}
},
"r1": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -75,7 +75,7 @@ description: Variables in memory after executing array_range_expr.kcl
]
},
"r2": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -120,7 +120,7 @@ description: Variables in memory after executing array_range_expr.kcl
]
},
"r3": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -173,7 +173,7 @@ description: Variables in memory after executing array_range_expr.kcl
]
},
"r4": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -4,7 +4,7 @@ description: Variables in memory after executing array_range_negative_expr.kcl
---
{
"xs": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -4,7 +4,7 @@ description: Variables in memory after executing computed_var.kcl
---
{
"arr": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -8,7 +8,7 @@ description: Variables in memory after executing double_map_fn.kcl
"value": null
},
"xs": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -37,7 +37,7 @@ description: Variables in memory after executing double_map_fn.kcl
]
},
"ys": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -614,7 +614,7 @@ description: Variables in memory after executing i_shape.kcl
}
},
"d_wrist_circumference": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -17,7 +17,7 @@ description: Variables in memory after executing import_async.kcl
}
},
"angles": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -1126,7 +1126,7 @@ description: Variables in memory after executing import_async.kcl
}
},
"invas": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2268,7 +2268,7 @@ description: Variables in memory after executing import_async.kcl
"value": null
},
"rs": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -86833,7 +86833,7 @@ description: Variables in memory after executing import_async.kcl
}
},
"xs": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -88164,7 +88164,7 @@ description: Variables in memory after executing import_async.kcl
]
},
"ys": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -4,7 +4,7 @@ description: Variables in memory after executing index_of_array.kcl
---
{
"arr": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -29,7 +29,7 @@ description: Variables in memory after executing dodecahedron.kcl
}
},
"dodecFaces": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Solid",
@ -2194,10 +2194,10 @@ description: Variables in memory after executing dodecahedron.kcl
]
},
"faceRotations": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2254,7 +2254,7 @@ description: Variables in memory after executing dodecahedron.kcl
]
},
{
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2311,7 +2311,7 @@ description: Variables in memory after executing dodecahedron.kcl
]
},
{
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2368,7 +2368,7 @@ description: Variables in memory after executing dodecahedron.kcl
]
},
{
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2425,7 +2425,7 @@ description: Variables in memory after executing dodecahedron.kcl
]
},
{
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2482,7 +2482,7 @@ description: Variables in memory after executing dodecahedron.kcl
]
},
{
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2539,7 +2539,7 @@ description: Variables in memory after executing dodecahedron.kcl
]
},
{
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2596,7 +2596,7 @@ description: Variables in memory after executing dodecahedron.kcl
]
},
{
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2653,7 +2653,7 @@ description: Variables in memory after executing dodecahedron.kcl
]
},
{
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2710,7 +2710,7 @@ description: Variables in memory after executing dodecahedron.kcl
]
},
{
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2767,7 +2767,7 @@ description: Variables in memory after executing dodecahedron.kcl
]
},
{
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2824,7 +2824,7 @@ description: Variables in memory after executing dodecahedron.kcl
]
},
{
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -2018,7 +2018,7 @@ description: Variables in memory after executing food-service-spatula.kcl
"type": "Object",
"value": {
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2062,7 +2062,7 @@ description: Variables in memory after executing food-service-spatula.kcl
]
},
"xAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2106,7 +2106,7 @@ description: Variables in memory after executing food-service-spatula.kcl
]
},
"yAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2150,7 +2150,7 @@ description: Variables in memory after executing food-service-spatula.kcl
]
},
"zAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -4190,7 +4190,7 @@ description: Variables in memory after executing french-press.kcl
"type": "Object",
"value": {
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -4234,7 +4234,7 @@ description: Variables in memory after executing french-press.kcl
]
},
"xAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -4278,7 +4278,7 @@ description: Variables in memory after executing french-press.kcl
]
},
"yAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -4322,7 +4322,7 @@ description: Variables in memory after executing french-press.kcl
]
},
"zAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -17,7 +17,7 @@ description: Variables in memory after executing gear.kcl
}
},
"angles": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -1126,7 +1126,7 @@ description: Variables in memory after executing gear.kcl
}
},
"invas": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -2261,7 +2261,7 @@ description: Variables in memory after executing gear.kcl
"value": null
},
"rs": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -86790,7 +86790,7 @@ description: Variables in memory after executing gear.kcl
}
},
"xs": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -88121,7 +88121,7 @@ description: Variables in memory after executing gear.kcl
]
},
"ys": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -7,7 +7,7 @@ description: Variables in memory after executing gridfinity-baseplate-magnets.kc
"type": "Object",
"value": {
"direction": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -38,7 +38,7 @@ description: Variables in memory after executing gridfinity-baseplate-magnets.kc
]
},
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -7,7 +7,7 @@ description: Variables in memory after executing gridfinity-baseplate.kcl
"type": "Object",
"value": {
"direction": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -38,7 +38,7 @@ description: Variables in memory after executing gridfinity-baseplate.kcl
]
},
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -12,7 +12,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
"type": "Object",
"value": {
"direction": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -43,7 +43,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
]
},
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -79,7 +79,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
"type": "Object",
"value": {
"direction": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -110,7 +110,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
]
},
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -20212,7 +20212,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
"type": "Object",
"value": {
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -20256,7 +20256,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
]
},
"xAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -20300,7 +20300,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
]
},
"yAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -20349,7 +20349,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
"type": "Object",
"value": {
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -20393,7 +20393,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
]
},
"xAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -20437,7 +20437,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
]
},
"yAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -20486,7 +20486,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
"type": "Object",
"value": {
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -20530,7 +20530,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
]
},
"xAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -20574,7 +20574,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
]
},
"yAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -7,7 +7,7 @@ description: Variables in memory after executing gridfinity-bins.kcl
"type": "Object",
"value": {
"direction": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -38,7 +38,7 @@ description: Variables in memory after executing gridfinity-bins.kcl
]
},
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -53,7 +53,7 @@ description: Variables in memory after executing keyboard.kcl
"type": "Object",
"value": {
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -97,7 +97,7 @@ description: Variables in memory after executing keyboard.kcl
]
},
"xAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -141,7 +141,7 @@ description: Variables in memory after executing keyboard.kcl
]
},
"yAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -180,7 +180,7 @@ description: Variables in memory after executing keyboard.kcl
]
},
"zAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -229,7 +229,7 @@ description: Variables in memory after executing keyboard.kcl
"type": "Object",
"value": {
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -273,7 +273,7 @@ description: Variables in memory after executing keyboard.kcl
]
},
"xAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -317,7 +317,7 @@ description: Variables in memory after executing keyboard.kcl
]
},
"yAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -356,7 +356,7 @@ description: Variables in memory after executing keyboard.kcl
]
},
"zAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",

View File

@ -569,7 +569,7 @@ description: Variables in memory after executing subtract_regression03.kcl
"type": "Object",
"value": {
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -613,7 +613,7 @@ description: Variables in memory after executing subtract_regression03.kcl
]
},
"xAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -657,7 +657,7 @@ description: Variables in memory after executing subtract_regression03.kcl
]
},
"yAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -701,7 +701,7 @@ description: Variables in memory after executing subtract_regression03.kcl
]
},
"zAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -750,7 +750,7 @@ description: Variables in memory after executing subtract_regression03.kcl
"type": "Object",
"value": {
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -794,7 +794,7 @@ description: Variables in memory after executing subtract_regression03.kcl
]
},
"xAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -838,7 +838,7 @@ description: Variables in memory after executing subtract_regression03.kcl
]
},
"yAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -882,7 +882,7 @@ description: Variables in memory after executing subtract_regression03.kcl
]
},
"zAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -931,7 +931,7 @@ description: Variables in memory after executing subtract_regression03.kcl
"type": "Object",
"value": {
"origin": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -975,7 +975,7 @@ description: Variables in memory after executing subtract_regression03.kcl
]
},
"xAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -1019,7 +1019,7 @@ description: Variables in memory after executing subtract_regression03.kcl
]
},
"yAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",
@ -1063,7 +1063,7 @@ description: Variables in memory after executing subtract_regression03.kcl
]
},
"zAxis": {
"type": "MixedArray",
"type": "HomArray",
"value": [
{
"type": "Number",