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:
@ -8,7 +8,7 @@ layout: manual
|
|||||||
Remove the last element from an array.
|
Remove the last element from an array.
|
||||||
|
|
||||||
```kcl
|
```kcl
|
||||||
pop(@array: [any]): any
|
pop(@array: [any]): [any]
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns a new array with the last element removed.
|
Returns a new array with the last element removed.
|
||||||
@ -21,7 +21,7 @@ Returns a new array with the last element removed.
|
|||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`any`](/docs/kcl-std/types/std-types-any) - Any KCL value.
|
[`[any]`](/docs/kcl-std/types/std-types-any)
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -11,7 +11,7 @@ Append an element to the end of an array.
|
|||||||
push(
|
push(
|
||||||
@array: [any],
|
@array: [any],
|
||||||
item: any,
|
item: any,
|
||||||
): any
|
): [any]
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns a new array with the element appended.
|
Returns a new array with the element appended.
|
||||||
@ -25,7 +25,7 @@ Returns a new array with the element appended.
|
|||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`any`](/docs/kcl-std/types/std-types-any) - Any KCL value.
|
[`[any]`](/docs/kcl-std/types/std-types-any)
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -126453,7 +126453,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -128940,7 +128940,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -131431,7 +131431,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -203225,7 +203225,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -205616,10 +205616,16 @@
|
|||||||
],
|
],
|
||||||
"returnValue": {
|
"returnValue": {
|
||||||
"name": "",
|
"name": "",
|
||||||
"type": "KclValue",
|
"type": "[KclValue]",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
"title": "KclValue",
|
"title": "Array_of_KclValue",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/KclValue"
|
||||||
|
},
|
||||||
|
"definitions": {
|
||||||
|
"KclValue": {
|
||||||
"description": "Any KCL value.",
|
"description": "Any KCL value.",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
@ -205710,7 +205716,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -206007,8 +206013,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"definitions": {
|
},
|
||||||
"NumericType": {
|
"NumericType": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
@ -206417,396 +206423,6 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"KclValue": {
|
|
||||||
"description": "Any KCL value.",
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Uuid"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Bool"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "boolean"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"ty",
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Number"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"ty": {
|
|
||||||
"$ref": "#/components/schemas/NumericType"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"String"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"MixedArray"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/KclValue"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"HomArray"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/KclValue"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Object"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": {
|
|
||||||
"$ref": "#/components/schemas/KclValue"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"TagIdentifier"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"TagDeclarator"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"digest": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint8",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"maxItems": 32,
|
|
||||||
"minItems": 32,
|
|
||||||
"nullable": true
|
|
||||||
},
|
|
||||||
"start": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Plane"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/Plane"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Face"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/Face"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Sketch"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/Sketch"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Solid"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/Solid"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Helix"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/Helix"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Data for an imported geometry.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"ImportedGeometry"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"description": "The ID of the imported geometry.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"description": "The original file paths.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Function"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/FunctionSource"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Module"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/ModuleId"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Type"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"KclNone"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/KclNone"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Plane": {
|
"Plane": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
@ -213703,7 +213319,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -216187,7 +215803,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -216577,7 +216193,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -218968,10 +218584,16 @@
|
|||||||
],
|
],
|
||||||
"returnValue": {
|
"returnValue": {
|
||||||
"name": "",
|
"name": "",
|
||||||
"type": "KclValue",
|
"type": "[KclValue]",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
"title": "KclValue",
|
"title": "Array_of_KclValue",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/KclValue"
|
||||||
|
},
|
||||||
|
"definitions": {
|
||||||
|
"KclValue": {
|
||||||
"description": "Any KCL value.",
|
"description": "Any KCL value.",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
@ -219062,7 +218684,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -219359,8 +218981,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"definitions": {
|
},
|
||||||
"NumericType": {
|
"NumericType": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
@ -219769,396 +219391,6 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"KclValue": {
|
|
||||||
"description": "Any KCL value.",
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Uuid"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Bool"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "boolean"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"ty",
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Number"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "double"
|
|
||||||
},
|
|
||||||
"ty": {
|
|
||||||
"$ref": "#/components/schemas/NumericType"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"String"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"MixedArray"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/KclValue"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"HomArray"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/KclValue"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Object"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": {
|
|
||||||
"$ref": "#/components/schemas/KclValue"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"TagIdentifier"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"TagDeclarator"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"digest": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint8",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"maxItems": 32,
|
|
||||||
"minItems": 32,
|
|
||||||
"nullable": true
|
|
||||||
},
|
|
||||||
"start": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint",
|
|
||||||
"minimum": 0.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Plane"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/Plane"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Face"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/Face"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Sketch"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/Sketch"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Solid"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/Solid"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Helix"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/Helix"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Data for an imported geometry.",
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"ImportedGeometry"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"description": "The ID of the imported geometry.",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uuid"
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"description": "The original file paths.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Function"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/FunctionSource"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Module"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/ModuleId"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Type"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"type",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"KclNone"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"$ref": "#/components/schemas/KclNone"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Plane": {
|
"Plane": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
@ -221959,7 +221191,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -224443,7 +223675,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -224833,7 +224065,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -227320,7 +226552,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -229805,7 +229037,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@ -230603,7 +229835,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"MixedArray"
|
"Tuple"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
|
@ -278,7 +278,7 @@ impl From<&KclValue> for OpKclValue {
|
|||||||
ty: ty.clone(),
|
ty: ty.clone(),
|
||||||
},
|
},
|
||||||
KclValue::String { value, .. } => Self::String { value: value.clone() },
|
KclValue::String { value, .. } => Self::String { value: value.clone() },
|
||||||
KclValue::MixedArray { value, .. } | KclValue::HomArray { value, .. } => {
|
KclValue::Tuple { value, .. } | KclValue::HomArray { value, .. } => {
|
||||||
let value = value.iter().map(Self::from).collect();
|
let value = value.iter().map(Self::from).collect();
|
||||||
Self::Array { value }
|
Self::Array { value }
|
||||||
}
|
}
|
||||||
|
@ -876,11 +876,7 @@ impl Node<MemberExpression> {
|
|||||||
source_ranges: vec![self.clone().into()],
|
source_ranges: vec![self.clone().into()],
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
(
|
(KclValue::HomArray { value: arr, .. }, Property::UInt(index), _) => {
|
||||||
KclValue::MixedArray { value: arr, .. } | KclValue::HomArray { value: arr, .. },
|
|
||||||
Property::UInt(index),
|
|
||||||
_,
|
|
||||||
) => {
|
|
||||||
let value_of_arr = arr.get(index);
|
let value_of_arr = arr.get(index);
|
||||||
if let Some(value) = value_of_arr {
|
if let Some(value) = value_of_arr {
|
||||||
Ok(value.to_owned())
|
Ok(value.to_owned())
|
||||||
@ -891,7 +887,7 @@ impl Node<MemberExpression> {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(KclValue::MixedArray { .. } | KclValue::HomArray { .. }, p, _) => {
|
(KclValue::HomArray { .. }, p, _) => {
|
||||||
let t = p.type_name();
|
let t = p.type_name();
|
||||||
let article = article_for(t);
|
let article = article_for(t);
|
||||||
Err(KclError::Semantic(KclErrorDetails {
|
Err(KclError::Semantic(KclErrorDetails {
|
||||||
@ -1179,7 +1175,7 @@ impl Node<UnaryExpression> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let direction = match direction {
|
let direction = match direction {
|
||||||
KclValue::MixedArray { value: values, meta } => {
|
KclValue::Tuple { value: values, meta } => {
|
||||||
let values = values
|
let values = values
|
||||||
.iter()
|
.iter()
|
||||||
.map(|v| match v {
|
.map(|v| match v {
|
||||||
@ -1192,7 +1188,7 @@ impl Node<UnaryExpression> {
|
|||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
KclValue::MixedArray {
|
KclValue::Tuple {
|
||||||
value: values,
|
value: values,
|
||||||
meta: meta.clone(),
|
meta: meta.clone(),
|
||||||
}
|
}
|
||||||
@ -1560,7 +1556,7 @@ fn update_memory_for_tags_of_geometry(result: &mut KclValue, exec_state: &mut Ex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KclValue::MixedArray { value, .. } | KclValue::HomArray { value, .. } => {
|
KclValue::Tuple { value, .. } | KclValue::HomArray { value, .. } => {
|
||||||
for v in value {
|
for v in value {
|
||||||
update_memory_for_tags_of_geometry(v, exec_state)?;
|
update_memory_for_tags_of_geometry(v, exec_state)?;
|
||||||
}
|
}
|
||||||
@ -1604,9 +1600,9 @@ impl Node<ArrayExpression> {
|
|||||||
results.push(value);
|
results.push(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(KclValue::MixedArray {
|
Ok(KclValue::HomArray {
|
||||||
value: results,
|
value: results,
|
||||||
meta: vec![self.into()],
|
ty: RuntimeType::Primitive(PrimitiveType::Any),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1653,7 +1649,8 @@ impl Node<ArrayRangeExpression> {
|
|||||||
let meta = vec![Metadata {
|
let meta = vec![Metadata {
|
||||||
source_range: self.into(),
|
source_range: self.into(),
|
||||||
}];
|
}];
|
||||||
Ok(KclValue::MixedArray {
|
|
||||||
|
Ok(KclValue::HomArray {
|
||||||
value: range
|
value: range
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|num| KclValue::Number {
|
.map(|num| KclValue::Number {
|
||||||
@ -1662,7 +1659,7 @@ impl Node<ArrayRangeExpression> {
|
|||||||
meta: meta.clone(),
|
meta: meta.clone(),
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
meta,
|
ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::count())),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1877,7 +1874,7 @@ fn type_check_params_kw(
|
|||||||
arg.value = arg
|
arg.value = arg
|
||||||
.value
|
.value
|
||||||
.coerce(
|
.coerce(
|
||||||
&RuntimeType::from_parsed(ty.inner.clone(), exec_state, arg.source_range).unwrap(),
|
&RuntimeType::from_parsed(ty.inner.clone(), exec_state, arg.source_range).map_err(|e| KclError::Semantic(e.into()))?,
|
||||||
exec_state,
|
exec_state,
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
@ -1955,7 +1952,8 @@ fn type_check_params_kw(
|
|||||||
arg.value = arg
|
arg.value = arg
|
||||||
.value
|
.value
|
||||||
.coerce(
|
.coerce(
|
||||||
&RuntimeType::from_parsed(ty.inner.clone(), exec_state, arg.source_range).unwrap(),
|
&RuntimeType::from_parsed(ty.inner.clone(), exec_state, arg.source_range)
|
||||||
|
.map_err(|e| KclError::Semantic(e.into()))?,
|
||||||
exec_state,
|
exec_state,
|
||||||
)
|
)
|
||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
@ -2134,7 +2132,8 @@ impl FunctionSource {
|
|||||||
arg.value = arg
|
arg.value = arg
|
||||||
.value
|
.value
|
||||||
.coerce(
|
.coerce(
|
||||||
&RuntimeType::from_parsed(ty.inner.clone(), exec_state, arg.source_range).unwrap(),
|
&RuntimeType::from_parsed(ty.inner.clone(), exec_state, arg.source_range)
|
||||||
|
.map_err(|e| KclError::Semantic(e.into()))?,
|
||||||
exec_state,
|
exec_state,
|
||||||
)
|
)
|
||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
@ -2244,9 +2243,10 @@ mod test {
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
exec::UnitType,
|
||||||
execution::{memory::Stack, parse_execute, ContextType},
|
execution::{memory::Stack, parse_execute, ContextType},
|
||||||
parsing::ast::types::{DefaultParamVal, Identifier, Parameter},
|
parsing::ast::types::{DefaultParamVal, Identifier, Parameter},
|
||||||
ExecutorSettings,
|
ExecutorSettings, UnitLen,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
@ -2400,6 +2400,7 @@ p = {
|
|||||||
yAxis = { x = 0, y = 1, z = 0 },
|
yAxis = { x = 0, y = 1, z = 0 },
|
||||||
zAxis = { x = 0, y = 0, z = 1 }
|
zAxis = { x = 0, y = 0, z = 1 }
|
||||||
}: Plane
|
}: Plane
|
||||||
|
arr1 = [42]: [number(cm)]
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
let result = parse_execute(program).await.unwrap();
|
let result = parse_execute(program).await.unwrap();
|
||||||
@ -2410,6 +2411,24 @@ p = {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
KclValue::Plane { .. }
|
KclValue::Plane { .. }
|
||||||
));
|
));
|
||||||
|
let arr1 = mem
|
||||||
|
.memory
|
||||||
|
.get_from("arr1", result.mem_env, SourceRange::default(), 0)
|
||||||
|
.unwrap();
|
||||||
|
if let KclValue::HomArray { value, ty } = arr1 {
|
||||||
|
assert_eq!(value.len(), 1, "Expected Vec with specific length: found {:?}", value);
|
||||||
|
assert_eq!(*ty, RuntimeType::known_length(UnitLen::Cm));
|
||||||
|
// Compare, ignoring meta.
|
||||||
|
if let KclValue::Number { value, ty, .. } = &value[0] {
|
||||||
|
// Converted from mm to cm.
|
||||||
|
assert_eq!(*value, 4.2);
|
||||||
|
assert_eq!(*ty, NumericType::Known(UnitType::Length(UnitLen::Cm)));
|
||||||
|
} else {
|
||||||
|
panic!("Expected a number; found {:?}", value[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
panic!("Expected HomArray; found {arr1:?}");
|
||||||
|
}
|
||||||
|
|
||||||
let program = r#"
|
let program = r#"
|
||||||
a = 42: string
|
a = 42: string
|
||||||
@ -2428,6 +2447,28 @@ a = 42: Plane
|
|||||||
.unwrap_err()
|
.unwrap_err()
|
||||||
.to_string()
|
.to_string()
|
||||||
.contains("could not coerce number value to type Plane"));
|
.contains("could not coerce number value to type Plane"));
|
||||||
|
|
||||||
|
let program = r#"
|
||||||
|
arr = [0]: [string]
|
||||||
|
"#;
|
||||||
|
let result = parse_execute(program).await;
|
||||||
|
let err = result.unwrap_err();
|
||||||
|
assert!(
|
||||||
|
err.to_string()
|
||||||
|
.contains("could not coerce array (list) value to type [string]"),
|
||||||
|
"Expected error but found {err:?}"
|
||||||
|
);
|
||||||
|
|
||||||
|
let program = r#"
|
||||||
|
mixedArr = [0, "a"]: [number(mm)]
|
||||||
|
"#;
|
||||||
|
let result = parse_execute(program).await;
|
||||||
|
let err = result.unwrap_err();
|
||||||
|
assert!(
|
||||||
|
err.to_string()
|
||||||
|
.contains("could not coerce array (list) value to type [number(mm)]"),
|
||||||
|
"Expected error but found {err:?}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
@ -1239,6 +1239,20 @@ impl Path {
|
|||||||
[TyF64::new(p[0], ty.clone()), TyF64::new(p[1], ty)]
|
[TyF64::new(p[0], ty.clone()), TyF64::new(p[1], ty)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The path segment start point and its type.
|
||||||
|
pub fn start_point_components(&self) -> ([f64; 2], NumericType) {
|
||||||
|
let p = &self.get_base().from;
|
||||||
|
let ty: NumericType = self.get_base().units.into();
|
||||||
|
(*p, ty)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The path segment end point and its type.
|
||||||
|
pub fn end_point_components(&self) -> ([f64; 2], NumericType) {
|
||||||
|
let p = &self.get_base().to;
|
||||||
|
let ty: NumericType = self.get_base().units.into();
|
||||||
|
(*p, ty)
|
||||||
|
}
|
||||||
|
|
||||||
/// Length of this path segment, in cartesian plane.
|
/// Length of this path segment, in cartesian plane.
|
||||||
pub fn length(&self) -> TyF64 {
|
pub fn length(&self) -> TyF64 {
|
||||||
let n = match self {
|
let n = match self {
|
||||||
|
@ -48,7 +48,7 @@ pub enum KclValue {
|
|||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
meta: Vec<Metadata>,
|
meta: Vec<Metadata>,
|
||||||
},
|
},
|
||||||
MixedArray {
|
Tuple {
|
||||||
value: Vec<KclValue>,
|
value: Vec<KclValue>,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
meta: Vec<Metadata>,
|
meta: Vec<Metadata>,
|
||||||
@ -197,7 +197,7 @@ impl From<KclValue> for Vec<SourceRange> {
|
|||||||
KclValue::Bool { meta, .. } => to_vec_sr(&meta),
|
KclValue::Bool { meta, .. } => to_vec_sr(&meta),
|
||||||
KclValue::Number { meta, .. } => to_vec_sr(&meta),
|
KclValue::Number { meta, .. } => to_vec_sr(&meta),
|
||||||
KclValue::String { meta, .. } => to_vec_sr(&meta),
|
KclValue::String { meta, .. } => to_vec_sr(&meta),
|
||||||
KclValue::MixedArray { meta, .. } => to_vec_sr(&meta),
|
KclValue::Tuple { meta, .. } => to_vec_sr(&meta),
|
||||||
KclValue::HomArray { value, .. } => value.iter().flat_map(Into::<Vec<SourceRange>>::into).collect(),
|
KclValue::HomArray { value, .. } => value.iter().flat_map(Into::<Vec<SourceRange>>::into).collect(),
|
||||||
KclValue::Object { meta, .. } => to_vec_sr(&meta),
|
KclValue::Object { meta, .. } => to_vec_sr(&meta),
|
||||||
KclValue::Module { meta, .. } => to_vec_sr(&meta),
|
KclValue::Module { meta, .. } => to_vec_sr(&meta),
|
||||||
@ -228,7 +228,7 @@ impl From<&KclValue> for Vec<SourceRange> {
|
|||||||
KclValue::Number { meta, .. } => to_vec_sr(meta),
|
KclValue::Number { meta, .. } => to_vec_sr(meta),
|
||||||
KclValue::String { meta, .. } => to_vec_sr(meta),
|
KclValue::String { meta, .. } => to_vec_sr(meta),
|
||||||
KclValue::Uuid { meta, .. } => to_vec_sr(meta),
|
KclValue::Uuid { meta, .. } => to_vec_sr(meta),
|
||||||
KclValue::MixedArray { meta, .. } => to_vec_sr(meta),
|
KclValue::Tuple { meta, .. } => to_vec_sr(meta),
|
||||||
KclValue::HomArray { value, .. } => value.iter().flat_map(Into::<Vec<SourceRange>>::into).collect(),
|
KclValue::HomArray { value, .. } => value.iter().flat_map(Into::<Vec<SourceRange>>::into).collect(),
|
||||||
KclValue::Object { meta, .. } => to_vec_sr(meta),
|
KclValue::Object { meta, .. } => to_vec_sr(meta),
|
||||||
KclValue::Module { meta, .. } => to_vec_sr(meta),
|
KclValue::Module { meta, .. } => to_vec_sr(meta),
|
||||||
@ -252,7 +252,7 @@ impl KclValue {
|
|||||||
KclValue::Bool { value: _, meta } => meta.clone(),
|
KclValue::Bool { value: _, meta } => meta.clone(),
|
||||||
KclValue::Number { meta, .. } => meta.clone(),
|
KclValue::Number { meta, .. } => meta.clone(),
|
||||||
KclValue::String { value: _, meta } => meta.clone(),
|
KclValue::String { value: _, meta } => meta.clone(),
|
||||||
KclValue::MixedArray { value: _, meta } => meta.clone(),
|
KclValue::Tuple { value: _, meta } => meta.clone(),
|
||||||
KclValue::HomArray { value, .. } => value.iter().flat_map(|v| v.metadata()).collect(),
|
KclValue::HomArray { value, .. } => value.iter().flat_map(|v| v.metadata()).collect(),
|
||||||
KclValue::Object { value: _, meta } => meta.clone(),
|
KclValue::Object { value: _, meta } => meta.clone(),
|
||||||
KclValue::TagIdentifier(x) => x.meta.clone(),
|
KclValue::TagIdentifier(x) => x.meta.clone(),
|
||||||
@ -307,7 +307,7 @@ impl KclValue {
|
|||||||
} => "number(Angle)",
|
} => "number(Angle)",
|
||||||
KclValue::Number { .. } => "number",
|
KclValue::Number { .. } => "number",
|
||||||
KclValue::String { .. } => "string (text)",
|
KclValue::String { .. } => "string (text)",
|
||||||
KclValue::MixedArray { .. } => "mixed array (list)",
|
KclValue::Tuple { .. } => "tuple (list)",
|
||||||
KclValue::HomArray { .. } => "array (list)",
|
KclValue::HomArray { .. } => "array (list)",
|
||||||
KclValue::Object { .. } => "object",
|
KclValue::Object { .. } => "object",
|
||||||
KclValue::Module { .. } => "module",
|
KclValue::Module { .. } => "module",
|
||||||
@ -373,7 +373,7 @@ impl KclValue {
|
|||||||
|
|
||||||
/// Put the point into a KCL value.
|
/// Put the point into a KCL value.
|
||||||
pub fn from_point2d(p: [f64; 2], ty: NumericType, meta: Vec<Metadata>) -> Self {
|
pub fn from_point2d(p: [f64; 2], ty: NumericType, meta: Vec<Metadata>) -> Self {
|
||||||
Self::MixedArray {
|
Self::Tuple {
|
||||||
value: vec![
|
value: vec![
|
||||||
Self::Number {
|
Self::Number {
|
||||||
value: p[0],
|
value: p[0],
|
||||||
@ -430,7 +430,7 @@ impl KclValue {
|
|||||||
|
|
||||||
pub fn as_array(&self) -> Option<&[KclValue]> {
|
pub fn as_array(&self) -> Option<&[KclValue]> {
|
||||||
match self {
|
match self {
|
||||||
KclValue::MixedArray { value, .. } | KclValue::HomArray { value, .. } => Some(value),
|
KclValue::Tuple { value, .. } | KclValue::HomArray { value, .. } => Some(value),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -602,7 +602,7 @@ impl KclValue {
|
|||||||
KclValue::TagDeclarator(tag) => Some(format!("${}", tag.name)),
|
KclValue::TagDeclarator(tag) => Some(format!("${}", tag.name)),
|
||||||
KclValue::TagIdentifier(tag) => Some(format!("${}", tag.value)),
|
KclValue::TagIdentifier(tag) => Some(format!("${}", tag.value)),
|
||||||
// TODO better Array and Object stringification
|
// TODO better Array and Object stringification
|
||||||
KclValue::MixedArray { .. } => Some("[...]".to_owned()),
|
KclValue::Tuple { .. } => Some("[...]".to_owned()),
|
||||||
KclValue::HomArray { .. } => Some("[...]".to_owned()),
|
KclValue::HomArray { .. } => Some("[...]".to_owned()),
|
||||||
KclValue::Object { .. } => Some("{ ... }".to_owned()),
|
KclValue::Object { .. } => Some("{ ... }".to_owned()),
|
||||||
KclValue::Module { .. }
|
KclValue::Module { .. }
|
||||||
|
@ -1932,7 +1932,7 @@ a = []
|
|||||||
notArray = !a";
|
notArray = !a";
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_execute(code5).await.unwrap_err().message(),
|
parse_execute(code5).await.unwrap_err().message(),
|
||||||
"Cannot apply unary operator ! to non-boolean value: mixed array (list)",
|
"Cannot apply unary operator ! to non-boolean value: array (list)",
|
||||||
);
|
);
|
||||||
|
|
||||||
let code6 = "
|
let code6 = "
|
||||||
|
@ -28,6 +28,10 @@ pub enum RuntimeType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RuntimeType {
|
impl RuntimeType {
|
||||||
|
pub fn any() -> Self {
|
||||||
|
RuntimeType::Primitive(PrimitiveType::Any)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn edge() -> Self {
|
pub fn edge() -> Self {
|
||||||
RuntimeType::Primitive(PrimitiveType::Edge)
|
RuntimeType::Primitive(PrimitiveType::Edge)
|
||||||
}
|
}
|
||||||
@ -166,6 +170,7 @@ impl RuntimeType {
|
|||||||
source_range: SourceRange,
|
source_range: SourceRange,
|
||||||
) -> Result<Self, CompilationError> {
|
) -> Result<Self, CompilationError> {
|
||||||
Ok(match value {
|
Ok(match value {
|
||||||
|
AstPrimitiveType::Any => RuntimeType::Primitive(PrimitiveType::Any),
|
||||||
AstPrimitiveType::String => RuntimeType::Primitive(PrimitiveType::String),
|
AstPrimitiveType::String => RuntimeType::Primitive(PrimitiveType::String),
|
||||||
AstPrimitiveType::Boolean => RuntimeType::Primitive(PrimitiveType::Boolean),
|
AstPrimitiveType::Boolean => RuntimeType::Primitive(PrimitiveType::Boolean),
|
||||||
AstPrimitiveType::Number(suffix) => RuntimeType::Primitive(PrimitiveType::Number(
|
AstPrimitiveType::Number(suffix) => RuntimeType::Primitive(PrimitiveType::Number(
|
||||||
@ -207,7 +212,7 @@ impl RuntimeType {
|
|||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(" or "),
|
.join(" or "),
|
||||||
RuntimeType::Tuple(tys) => format!(
|
RuntimeType::Tuple(tys) => format!(
|
||||||
"an array with values of types ({})",
|
"a tuple with values of types ({})",
|
||||||
tys.iter().map(Self::human_friendly_type).collect::<Vec<_>>().join(", ")
|
tys.iter().map(Self::human_friendly_type).collect::<Vec<_>>().join(", ")
|
||||||
),
|
),
|
||||||
RuntimeType::Object(_) => format!("an object with fields {}", self),
|
RuntimeType::Object(_) => format!("an object with fields {}", self),
|
||||||
@ -219,6 +224,7 @@ impl RuntimeType {
|
|||||||
use RuntimeType::*;
|
use RuntimeType::*;
|
||||||
|
|
||||||
match (self, sup) {
|
match (self, sup) {
|
||||||
|
(_, Primitive(PrimitiveType::Any)) => true,
|
||||||
(Primitive(t1), Primitive(t2)) => t1.subtype(t2),
|
(Primitive(t1), Primitive(t2)) => t1.subtype(t2),
|
||||||
(Array(t1, l1), Array(t2, l2)) => t1.subtype(t2) && l1.subtype(*l2),
|
(Array(t1, l1), Array(t2, l2)) => t1.subtype(t2) && l1.subtype(*l2),
|
||||||
(Tuple(t1), Tuple(t2)) => t1.len() == t2.len() && t1.iter().zip(t2).all(|(t1, t2)| t1.subtype(t2)),
|
(Tuple(t1), Tuple(t2)) => t1.len() == t2.len() && t1.iter().zip(t2).all(|(t1, t2)| t1.subtype(t2)),
|
||||||
@ -269,7 +275,7 @@ impl RuntimeType {
|
|||||||
.map(|t| t.display_multiple())
|
.map(|t| t.display_multiple())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(" or "),
|
.join(" or "),
|
||||||
RuntimeType::Tuple(_) => "arrays".to_owned(),
|
RuntimeType::Tuple(_) => "tuples".to_owned(),
|
||||||
RuntimeType::Object(_) => format!("objects with fields {self}"),
|
RuntimeType::Object(_) => format!("objects with fields {self}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -286,7 +292,7 @@ impl fmt::Display for RuntimeType {
|
|||||||
},
|
},
|
||||||
RuntimeType::Tuple(ts) => write!(
|
RuntimeType::Tuple(ts) => write!(
|
||||||
f,
|
f,
|
||||||
"[{}]",
|
"({})",
|
||||||
ts.iter().map(|t| t.to_string()).collect::<Vec<_>>().join(", ")
|
ts.iter().map(|t| t.to_string()).collect::<Vec<_>>().join(", ")
|
||||||
),
|
),
|
||||||
RuntimeType::Union(ts) => write!(
|
RuntimeType::Union(ts) => write!(
|
||||||
@ -337,6 +343,7 @@ impl ArrayLen {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum PrimitiveType {
|
pub enum PrimitiveType {
|
||||||
|
Any,
|
||||||
Number(NumericType),
|
Number(NumericType),
|
||||||
String,
|
String,
|
||||||
Boolean,
|
Boolean,
|
||||||
@ -357,6 +364,7 @@ pub enum PrimitiveType {
|
|||||||
impl PrimitiveType {
|
impl PrimitiveType {
|
||||||
fn display_multiple(&self) -> String {
|
fn display_multiple(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
|
PrimitiveType::Any => "any values".to_owned(),
|
||||||
PrimitiveType::Number(NumericType::Known(unit)) => format!("numbers({unit})"),
|
PrimitiveType::Number(NumericType::Known(unit)) => format!("numbers({unit})"),
|
||||||
PrimitiveType::Number(_) => "numbers".to_owned(),
|
PrimitiveType::Number(_) => "numbers".to_owned(),
|
||||||
PrimitiveType::String => "strings".to_owned(),
|
PrimitiveType::String => "strings".to_owned(),
|
||||||
@ -377,6 +385,7 @@ impl PrimitiveType {
|
|||||||
|
|
||||||
fn subtype(&self, other: &PrimitiveType) -> bool {
|
fn subtype(&self, other: &PrimitiveType) -> bool {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
|
(_, PrimitiveType::Any) => true,
|
||||||
(PrimitiveType::Number(n1), PrimitiveType::Number(n2)) => n1.subtype(n2),
|
(PrimitiveType::Number(n1), PrimitiveType::Number(n2)) => n1.subtype(n2),
|
||||||
(PrimitiveType::TagId, PrimitiveType::Tag) => true,
|
(PrimitiveType::TagId, PrimitiveType::Tag) => true,
|
||||||
(t1, t2) => t1 == t2,
|
(t1, t2) => t1 == t2,
|
||||||
@ -387,6 +396,7 @@ impl PrimitiveType {
|
|||||||
impl fmt::Display for PrimitiveType {
|
impl fmt::Display for PrimitiveType {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
PrimitiveType::Any => write!(f, "any"),
|
||||||
PrimitiveType::Number(NumericType::Known(unit)) => write!(f, "number({unit})"),
|
PrimitiveType::Number(NumericType::Known(unit)) => write!(f, "number({unit})"),
|
||||||
PrimitiveType::Number(NumericType::Unknown) => write!(f, "number(unknown units)"),
|
PrimitiveType::Number(NumericType::Unknown) => write!(f, "number(unknown units)"),
|
||||||
PrimitiveType::Number(NumericType::Default { .. }) => write!(f, "number(default units)"),
|
PrimitiveType::Number(NumericType::Default { .. }) => write!(f, "number(default units)"),
|
||||||
@ -1003,9 +1013,9 @@ impl KclValue {
|
|||||||
self_ty.subtype(ty)
|
self_ty.subtype(ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Coerce `self` to a new value which has `ty` as it's closest supertype.
|
/// Coerce `self` to a new value which has `ty` as its closest supertype.
|
||||||
///
|
///
|
||||||
/// If the result is Some, then:
|
/// If the result is Ok, then:
|
||||||
/// - result.principal_type().unwrap().subtype(ty)
|
/// - result.principal_type().unwrap().subtype(ty)
|
||||||
///
|
///
|
||||||
/// If self.principal_type() == ty then result == self
|
/// If self.principal_type() == ty then result == self
|
||||||
@ -1025,10 +1035,11 @@ impl KclValue {
|
|||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
) -> Result<KclValue, CoercionError> {
|
) -> Result<KclValue, CoercionError> {
|
||||||
let value = match self {
|
let value = match self {
|
||||||
KclValue::MixedArray { value, .. } | KclValue::HomArray { value, .. } if value.len() == 1 => &value[0],
|
KclValue::Tuple { value, .. } | KclValue::HomArray { value, .. } if value.len() == 1 => &value[0],
|
||||||
_ => self,
|
_ => self,
|
||||||
};
|
};
|
||||||
match ty {
|
match ty {
|
||||||
|
PrimitiveType::Any => Ok(value.clone()),
|
||||||
PrimitiveType::Number(ty) => ty.coerce(value),
|
PrimitiveType::Number(ty) => ty.coerce(value),
|
||||||
PrimitiveType::String => match value {
|
PrimitiveType::String => match value {
|
||||||
KclValue::String { .. } => Ok(value.clone()),
|
KclValue::String { .. } => Ok(value.clone()),
|
||||||
@ -1191,41 +1202,49 @@ impl KclValue {
|
|||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
allow_shrink: bool,
|
allow_shrink: bool,
|
||||||
) -> Result<KclValue, CoercionError> {
|
) -> Result<KclValue, CoercionError> {
|
||||||
if len.satisfied(1, false).is_some() && self.has_type(ty) {
|
|
||||||
return Ok(KclValue::HomArray {
|
|
||||||
value: vec![self.clone()],
|
|
||||||
ty: ty.clone(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
match self {
|
match self {
|
||||||
KclValue::HomArray { value, ty: aty } => {
|
KclValue::HomArray { value, ty: aty, .. } => {
|
||||||
|
let satisfied_len = len.satisfied(value.len(), allow_shrink);
|
||||||
|
|
||||||
if aty.subtype(ty) {
|
if aty.subtype(ty) {
|
||||||
len.satisfied(value.len(), allow_shrink)
|
// If the element type is a subtype of the target type and
|
||||||
|
// the length constraint is satisfied, we can just return
|
||||||
|
// the values unchanged, only adjusting the length. The new
|
||||||
|
// array element type should preserve its type because the
|
||||||
|
// target type oftentimes includes an unknown type as a way
|
||||||
|
// to say that the caller doesn't care.
|
||||||
|
return satisfied_len
|
||||||
.map(|len| KclValue::HomArray {
|
.map(|len| KclValue::HomArray {
|
||||||
value: value[..len].to_vec(),
|
value: value[..len].to_vec(),
|
||||||
ty: aty.clone(),
|
ty: aty.clone(),
|
||||||
})
|
})
|
||||||
.ok_or(self.into())
|
.ok_or(self.into());
|
||||||
} else {
|
}
|
||||||
Err(self.into())
|
|
||||||
|
// Ignore the array type, and coerce the elements of the array.
|
||||||
|
if let Some(satisfied_len) = satisfied_len {
|
||||||
|
let value_result = value
|
||||||
|
.iter()
|
||||||
|
.take(satisfied_len)
|
||||||
|
.map(|v| v.coerce(ty, exec_state))
|
||||||
|
.collect::<Result<Vec<_>, _>>();
|
||||||
|
|
||||||
|
if let Ok(value) = value_result {
|
||||||
|
// We were able to coerce all the elements.
|
||||||
|
return Ok(KclValue::HomArray { value, ty: ty.clone() });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KclValue::MixedArray { value, .. } => {
|
|
||||||
// Check if we have a nested homogeneous array that we can flatten.
|
// As a last resort, try to flatten the array.
|
||||||
let mut values = Vec::new();
|
let mut values = Vec::new();
|
||||||
for item in value {
|
for item in value {
|
||||||
if let KclValue::HomArray {
|
if let KclValue::HomArray { value: inner_value, .. } = item {
|
||||||
ty: inner_ty,
|
// Flatten elements.
|
||||||
value: inner_value,
|
for item in inner_value {
|
||||||
} = item
|
values.push(item.coerce(ty, exec_state)?);
|
||||||
{
|
|
||||||
if inner_ty.subtype(ty) {
|
|
||||||
values.extend(inner_value.iter().cloned());
|
|
||||||
} else {
|
|
||||||
values.push(item.clone());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
values.push(item.clone());
|
values.push(item.coerce(ty, exec_state)?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1233,9 +1252,22 @@ impl KclValue {
|
|||||||
.satisfied(values.len(), allow_shrink)
|
.satisfied(values.len(), allow_shrink)
|
||||||
.ok_or(CoercionError::from(self))?;
|
.ok_or(CoercionError::from(self))?;
|
||||||
|
|
||||||
let value = values[..len]
|
assert!(len <= values.len());
|
||||||
|
values.truncate(len);
|
||||||
|
|
||||||
|
Ok(KclValue::HomArray {
|
||||||
|
value: values,
|
||||||
|
ty: ty.clone(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
KclValue::Tuple { value, .. } => {
|
||||||
|
let len = len
|
||||||
|
.satisfied(value.len(), allow_shrink)
|
||||||
|
.ok_or(CoercionError::from(self))?;
|
||||||
|
let value = value
|
||||||
.iter()
|
.iter()
|
||||||
.map(|v| v.coerce(ty, exec_state))
|
.map(|item| item.coerce(ty, exec_state))
|
||||||
|
.take(len)
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
Ok(KclValue::HomArray { value, ty: ty.clone() })
|
Ok(KclValue::HomArray { value, ty: ty.clone() })
|
||||||
@ -1244,28 +1276,32 @@ impl KclValue {
|
|||||||
value: Vec::new(),
|
value: Vec::new(),
|
||||||
ty: ty.clone(),
|
ty: ty.clone(),
|
||||||
}),
|
}),
|
||||||
|
_ if len.satisfied(1, false).is_some() => Ok(KclValue::HomArray {
|
||||||
|
value: vec![self.coerce(ty, exec_state)?],
|
||||||
|
ty: ty.clone(),
|
||||||
|
}),
|
||||||
_ => Err(self.into()),
|
_ => Err(self.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn coerce_to_tuple_type(&self, tys: &[RuntimeType], exec_state: &mut ExecState) -> Result<KclValue, CoercionError> {
|
fn coerce_to_tuple_type(&self, tys: &[RuntimeType], exec_state: &mut ExecState) -> Result<KclValue, CoercionError> {
|
||||||
match self {
|
match self {
|
||||||
KclValue::MixedArray { value, .. } | KclValue::HomArray { value, .. } if value.len() == tys.len() => {
|
KclValue::Tuple { value, .. } | KclValue::HomArray { value, .. } if value.len() == tys.len() => {
|
||||||
let mut result = Vec::new();
|
let mut result = Vec::new();
|
||||||
for (i, t) in tys.iter().enumerate() {
|
for (i, t) in tys.iter().enumerate() {
|
||||||
result.push(value[i].coerce(t, exec_state)?);
|
result.push(value[i].coerce(t, exec_state)?);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(KclValue::MixedArray {
|
Ok(KclValue::Tuple {
|
||||||
value: result,
|
value: result,
|
||||||
meta: Vec::new(),
|
meta: Vec::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
KclValue::KclNone { meta, .. } if tys.is_empty() => Ok(KclValue::MixedArray {
|
KclValue::KclNone { meta, .. } if tys.is_empty() => Ok(KclValue::Tuple {
|
||||||
value: Vec::new(),
|
value: Vec::new(),
|
||||||
meta: meta.clone(),
|
meta: meta.clone(),
|
||||||
}),
|
}),
|
||||||
value if tys.len() == 1 && value.has_type(&tys[0]) => Ok(KclValue::MixedArray {
|
value if tys.len() == 1 && value.has_type(&tys[0]) => Ok(KclValue::Tuple {
|
||||||
value: vec![value.clone()],
|
value: vec![value.clone()],
|
||||||
meta: Vec::new(),
|
meta: Vec::new(),
|
||||||
}),
|
}),
|
||||||
@ -1325,7 +1361,7 @@ impl KclValue {
|
|||||||
KclValue::Face { .. } => Some(RuntimeType::Primitive(PrimitiveType::Face)),
|
KclValue::Face { .. } => Some(RuntimeType::Primitive(PrimitiveType::Face)),
|
||||||
KclValue::Helix { .. } => Some(RuntimeType::Primitive(PrimitiveType::Helix)),
|
KclValue::Helix { .. } => Some(RuntimeType::Primitive(PrimitiveType::Helix)),
|
||||||
KclValue::ImportedGeometry(..) => Some(RuntimeType::Primitive(PrimitiveType::ImportedGeometry)),
|
KclValue::ImportedGeometry(..) => Some(RuntimeType::Primitive(PrimitiveType::ImportedGeometry)),
|
||||||
KclValue::MixedArray { value, .. } => Some(RuntimeType::Tuple(
|
KclValue::Tuple { value, .. } => Some(RuntimeType::Tuple(
|
||||||
value.iter().map(|v| v.principal_type()).collect::<Option<Vec<_>>>()?,
|
value.iter().map(|v| v.principal_type()).collect::<Option<Vec<_>>>()?,
|
||||||
)),
|
)),
|
||||||
KclValue::HomArray { ty, value, .. } => {
|
KclValue::HomArray { ty, value, .. } => {
|
||||||
@ -1361,7 +1397,7 @@ mod test {
|
|||||||
value: "hello".to_owned(),
|
value: "hello".to_owned(),
|
||||||
meta: Vec::new(),
|
meta: Vec::new(),
|
||||||
},
|
},
|
||||||
KclValue::MixedArray {
|
KclValue::Tuple {
|
||||||
value: Vec::new(),
|
value: Vec::new(),
|
||||||
meta: Vec::new(),
|
meta: Vec::new(),
|
||||||
},
|
},
|
||||||
@ -1430,6 +1466,26 @@ mod test {
|
|||||||
let aty1 = RuntimeType::Array(Box::new(ty.clone()), ArrayLen::Known(1));
|
let aty1 = RuntimeType::Array(Box::new(ty.clone()), ArrayLen::Known(1));
|
||||||
let aty0 = RuntimeType::Array(Box::new(ty.clone()), ArrayLen::NonEmpty);
|
let aty0 = RuntimeType::Array(Box::new(ty.clone()), ArrayLen::NonEmpty);
|
||||||
|
|
||||||
|
match v {
|
||||||
|
KclValue::Tuple { .. } | KclValue::HomArray { .. } => {
|
||||||
|
// These will not get wrapped if possible.
|
||||||
|
assert_coerce_results(
|
||||||
|
v,
|
||||||
|
&aty,
|
||||||
|
&KclValue::HomArray {
|
||||||
|
value: vec![],
|
||||||
|
ty: ty.clone(),
|
||||||
|
},
|
||||||
|
&mut exec_state,
|
||||||
|
);
|
||||||
|
// Coercing an empty tuple or array to an array of length 1
|
||||||
|
// should fail.
|
||||||
|
v.coerce(&aty1, &mut exec_state).unwrap_err();
|
||||||
|
// Coercing an empty tuple or array to an array that's
|
||||||
|
// non-empty should fail.
|
||||||
|
v.coerce(&aty0, &mut exec_state).unwrap_err();
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
assert_coerce_results(
|
assert_coerce_results(
|
||||||
v,
|
v,
|
||||||
&aty,
|
&aty,
|
||||||
@ -1463,13 +1519,15 @@ mod test {
|
|||||||
assert_coerce_results(
|
assert_coerce_results(
|
||||||
v,
|
v,
|
||||||
&tty,
|
&tty,
|
||||||
&KclValue::MixedArray {
|
&KclValue::Tuple {
|
||||||
value: vec![v.clone()],
|
value: vec![v.clone()],
|
||||||
meta: Vec::new(),
|
meta: Vec::new(),
|
||||||
},
|
},
|
||||||
&mut exec_state,
|
&mut exec_state,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for v in &values[1..] {
|
for v in &values[1..] {
|
||||||
// Not a subtype
|
// Not a subtype
|
||||||
@ -1516,7 +1574,7 @@ mod test {
|
|||||||
assert_coerce_results(
|
assert_coerce_results(
|
||||||
&none,
|
&none,
|
||||||
&tty,
|
&tty,
|
||||||
&KclValue::MixedArray {
|
&KclValue::Tuple {
|
||||||
value: Vec::new(),
|
value: Vec::new(),
|
||||||
meta: Vec::new(),
|
meta: Vec::new(),
|
||||||
},
|
},
|
||||||
@ -1647,7 +1705,7 @@ mod test {
|
|||||||
],
|
],
|
||||||
ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::count())),
|
ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::count())),
|
||||||
};
|
};
|
||||||
let mixed1 = KclValue::MixedArray {
|
let mixed1 = KclValue::Tuple {
|
||||||
value: vec![
|
value: vec![
|
||||||
KclValue::Number {
|
KclValue::Number {
|
||||||
value: 0.0,
|
value: 0.0,
|
||||||
@ -1662,7 +1720,7 @@ mod test {
|
|||||||
],
|
],
|
||||||
meta: Vec::new(),
|
meta: Vec::new(),
|
||||||
};
|
};
|
||||||
let mixed2 = KclValue::MixedArray {
|
let mixed2 = KclValue::Tuple {
|
||||||
value: vec![
|
value: vec![
|
||||||
KclValue::Number {
|
KclValue::Number {
|
||||||
value: 0.0,
|
value: 0.0,
|
||||||
@ -1752,7 +1810,7 @@ mod test {
|
|||||||
],
|
],
|
||||||
ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::count())),
|
ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::count())),
|
||||||
};
|
};
|
||||||
let mixed0 = KclValue::MixedArray {
|
let mixed0 = KclValue::Tuple {
|
||||||
value: vec![],
|
value: vec![],
|
||||||
meta: Vec::new(),
|
meta: Vec::new(),
|
||||||
};
|
};
|
||||||
@ -2169,7 +2227,7 @@ d = cos(30)
|
|||||||
async fn coerce_nested_array() {
|
async fn coerce_nested_array() {
|
||||||
let mut exec_state = ExecState::new(&crate::ExecutorContext::new_mock().await);
|
let mut exec_state = ExecState::new(&crate::ExecutorContext::new_mock().await);
|
||||||
|
|
||||||
let mixed1 = KclValue::MixedArray {
|
let mixed1 = KclValue::HomArray {
|
||||||
value: vec![
|
value: vec![
|
||||||
KclValue::Number {
|
KclValue::Number {
|
||||||
value: 0.0,
|
value: 0.0,
|
||||||
@ -2197,7 +2255,7 @@ d = cos(30)
|
|||||||
ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::count())),
|
ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::count())),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
meta: Vec::new(),
|
ty: RuntimeType::any(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Principal types
|
// Principal types
|
||||||
|
@ -226,6 +226,7 @@ impl PrimitiveType {
|
|||||||
pub fn compute_digest(&mut self) -> Digest {
|
pub fn compute_digest(&mut self) -> Digest {
|
||||||
let mut hasher = Sha256::new();
|
let mut hasher = Sha256::new();
|
||||||
match self {
|
match self {
|
||||||
|
PrimitiveType::Any => hasher.update(b"any"),
|
||||||
PrimitiveType::Named(id) => hasher.update(id.compute_digest()),
|
PrimitiveType::Named(id) => hasher.update(id.compute_digest()),
|
||||||
PrimitiveType::String => hasher.update(b"string"),
|
PrimitiveType::String => hasher.update(b"string"),
|
||||||
PrimitiveType::Number(suffix) => hasher.update(suffix.digestable_id()),
|
PrimitiveType::Number(suffix) => hasher.update(suffix.digestable_id()),
|
||||||
|
@ -3186,6 +3186,8 @@ impl PipeExpression {
|
|||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
#[serde(tag = "p_type")]
|
#[serde(tag = "p_type")]
|
||||||
pub enum PrimitiveType {
|
pub enum PrimitiveType {
|
||||||
|
/// The super type of all other types.
|
||||||
|
Any,
|
||||||
/// A string type.
|
/// A string type.
|
||||||
String,
|
String,
|
||||||
/// A number type.
|
/// A number type.
|
||||||
@ -3202,6 +3204,7 @@ pub enum PrimitiveType {
|
|||||||
impl PrimitiveType {
|
impl PrimitiveType {
|
||||||
pub fn primitive_from_str(s: &str, suffix: Option<NumericSuffix>) -> Option<Self> {
|
pub fn primitive_from_str(s: &str, suffix: Option<NumericSuffix>) -> Option<Self> {
|
||||||
match (s, suffix) {
|
match (s, suffix) {
|
||||||
|
("any", None) => Some(PrimitiveType::Any),
|
||||||
("string", None) => Some(PrimitiveType::String),
|
("string", None) => Some(PrimitiveType::String),
|
||||||
("bool", None) => Some(PrimitiveType::Boolean),
|
("bool", None) => Some(PrimitiveType::Boolean),
|
||||||
("tag", None) => Some(PrimitiveType::Tag),
|
("tag", None) => Some(PrimitiveType::Tag),
|
||||||
@ -3215,6 +3218,7 @@ impl PrimitiveType {
|
|||||||
impl fmt::Display for PrimitiveType {
|
impl fmt::Display for PrimitiveType {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
PrimitiveType::Any => write!(f, "any"),
|
||||||
PrimitiveType::Number(suffix) => {
|
PrimitiveType::Number(suffix) => {
|
||||||
write!(f, "number")?;
|
write!(f, "number")?;
|
||||||
if *suffix != NumericSuffix::None {
|
if *suffix != NumericSuffix::None {
|
||||||
|
@ -2757,9 +2757,9 @@ fn labeled_argument(i: &mut TokenSlice) -> PResult<LabeledArg> {
|
|||||||
|
|
||||||
/// A type of a function argument.
|
/// A type of a function argument.
|
||||||
/// This can be:
|
/// This can be:
|
||||||
/// - a primitive type, e.g. 'number' or 'string' or 'bool'
|
/// - a primitive type, e.g. `number` or `string` or `bool`
|
||||||
/// - an array type, e.g. 'number[]' or 'string[]' or 'bool[]'
|
/// - an array type, e.g. `[number]` or `[string]` or `[bool]`
|
||||||
/// - an object type, e.g. '{x: number, y: number}' or '{name: string, age: number}'
|
/// - an object type, e.g. `{x: number, y: number}` or `{name: string, age: number}`
|
||||||
fn argument_type(i: &mut TokenSlice) -> PResult<Node<Type>> {
|
fn argument_type(i: &mut TokenSlice) -> PResult<Node<Type>> {
|
||||||
let type_ = alt((
|
let type_ = alt((
|
||||||
// Object types
|
// Object types
|
||||||
|
@ -363,6 +363,27 @@ mod cube_with_error {
|
|||||||
super::execute(TEST_NAME, true).await
|
super::execute(TEST_NAME, true).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mod any_type {
|
||||||
|
const TEST_NAME: &str = "any_type";
|
||||||
|
|
||||||
|
/// Test parsing KCL.
|
||||||
|
#[test]
|
||||||
|
fn parse() {
|
||||||
|
super::parse(TEST_NAME)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn unparse() {
|
||||||
|
super::unparse(TEST_NAME).await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test that KCL is executed correctly.
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn kcl_test_execute() {
|
||||||
|
super::execute(TEST_NAME, false).await
|
||||||
|
}
|
||||||
|
}
|
||||||
mod artifact_graph_example_code1 {
|
mod artifact_graph_example_code1 {
|
||||||
const TEST_NAME: &str = "artifact_graph_example_code1";
|
const TEST_NAME: &str = "artifact_graph_example_code1";
|
||||||
|
|
||||||
@ -1144,6 +1165,27 @@ mod array_elem_push_fail {
|
|||||||
super::execute(TEST_NAME, false).await
|
super::execute(TEST_NAME, false).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mod array_push_item_wrong_type {
|
||||||
|
const TEST_NAME: &str = "array_push_item_wrong_type";
|
||||||
|
|
||||||
|
/// Test parsing KCL.
|
||||||
|
#[test]
|
||||||
|
fn parse() {
|
||||||
|
super::parse(TEST_NAME)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn unparse() {
|
||||||
|
super::unparse(TEST_NAME).await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test that KCL is executed correctly.
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn kcl_test_execute() {
|
||||||
|
super::execute(TEST_NAME, false).await
|
||||||
|
}
|
||||||
|
}
|
||||||
mod sketch_on_face {
|
mod sketch_on_face {
|
||||||
const TEST_NAME: &str = "sketch_on_face";
|
const TEST_NAME: &str = "sketch_on_face";
|
||||||
|
|
||||||
|
@ -557,24 +557,23 @@ impl Args {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn make_user_val_from_point(&self, p: [TyF64; 2]) -> Result<KclValue, KclError> {
|
pub(crate) fn make_kcl_val_from_point(&self, p: [f64; 2], ty: NumericType) -> Result<KclValue, KclError> {
|
||||||
let meta = Metadata {
|
let meta = Metadata {
|
||||||
source_range: self.source_range,
|
source_range: self.source_range,
|
||||||
};
|
};
|
||||||
let x = KclValue::Number {
|
let x = KclValue::Number {
|
||||||
value: p[0].n,
|
value: p[0],
|
||||||
meta: vec![meta],
|
meta: vec![meta],
|
||||||
ty: p[0].ty.clone(),
|
ty: ty.clone(),
|
||||||
};
|
};
|
||||||
let y = KclValue::Number {
|
let y = KclValue::Number {
|
||||||
value: p[1].n,
|
value: p[1],
|
||||||
meta: vec![meta],
|
meta: vec![meta],
|
||||||
ty: p[1].ty.clone(),
|
ty: ty.clone(),
|
||||||
};
|
};
|
||||||
Ok(KclValue::MixedArray {
|
let ty = RuntimeType::Primitive(PrimitiveType::Number(ty));
|
||||||
value: vec![x, y],
|
|
||||||
meta: vec![meta],
|
Ok(KclValue::HomArray { value: vec![x, y], ty })
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn make_user_val_from_f64_with_type(&self, f: TyF64) -> KclValue {
|
pub(super) fn make_user_val_from_f64_with_type(&self, f: TyF64) -> KclValue {
|
||||||
@ -796,7 +795,7 @@ impl<'a> FromKclValue<'a> for Vec<TagIdentifier> {
|
|||||||
let tags = value.iter().map(|v| v.get_tag_identifier().unwrap()).collect();
|
let tags = value.iter().map(|v| v.get_tag_identifier().unwrap()).collect();
|
||||||
Some(tags)
|
Some(tags)
|
||||||
}
|
}
|
||||||
KclValue::MixedArray { value, .. } => {
|
KclValue::Tuple { value, .. } => {
|
||||||
let tags = value.iter().map(|v| v.get_tag_identifier().unwrap()).collect();
|
let tags = value.iter().map(|v| v.get_tag_identifier().unwrap()).collect();
|
||||||
Some(tags)
|
Some(tags)
|
||||||
}
|
}
|
||||||
@ -1136,8 +1135,11 @@ impl_from_kcl_for_vec!(TyF64);
|
|||||||
|
|
||||||
impl<'a> FromKclValue<'a> for SourceRange {
|
impl<'a> FromKclValue<'a> for SourceRange {
|
||||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||||
let KclValue::MixedArray { value, meta: _ } = arg else {
|
let value = match arg {
|
||||||
|
KclValue::Tuple { value, .. } | KclValue::HomArray { value, .. } => value,
|
||||||
|
_ => {
|
||||||
return None;
|
return None;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if value.len() != 3 {
|
if value.len() != 3 {
|
||||||
return None;
|
return None;
|
||||||
@ -1334,7 +1336,7 @@ impl<'a> FromKclValue<'a> for TyF64 {
|
|||||||
impl<'a> FromKclValue<'a> for [TyF64; 2] {
|
impl<'a> FromKclValue<'a> for [TyF64; 2] {
|
||||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||||
match arg {
|
match arg {
|
||||||
KclValue::MixedArray { value, meta: _ } | KclValue::HomArray { value, .. } => {
|
KclValue::Tuple { value, meta: _ } | KclValue::HomArray { value, .. } => {
|
||||||
if value.len() != 2 {
|
if value.len() != 2 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -1351,7 +1353,7 @@ impl<'a> FromKclValue<'a> for [TyF64; 2] {
|
|||||||
impl<'a> FromKclValue<'a> for [TyF64; 3] {
|
impl<'a> FromKclValue<'a> for [TyF64; 3] {
|
||||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||||
match arg {
|
match arg {
|
||||||
KclValue::MixedArray { value, meta: _ } | KclValue::HomArray { value, .. } => {
|
KclValue::Tuple { value, meta: _ } | KclValue::HomArray { value, .. } => {
|
||||||
if value.len() != 3 {
|
if value.len() != 3 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ use crate::{
|
|||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
execution::{
|
execution::{
|
||||||
kcl_value::{FunctionSource, KclValue},
|
kcl_value::{FunctionSource, KclValue},
|
||||||
|
types::RuntimeType,
|
||||||
ExecState,
|
ExecState,
|
||||||
},
|
},
|
||||||
source_range::SourceRange,
|
source_range::SourceRange,
|
||||||
@ -19,9 +20,11 @@ use crate::{
|
|||||||
pub async fn map(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
pub async fn map(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||||
let array: Vec<KclValue> = args.get_unlabeled_kw_arg("array")?;
|
let array: Vec<KclValue> = args.get_unlabeled_kw_arg("array")?;
|
||||||
let f: &FunctionSource = args.get_kw_arg("f")?;
|
let f: &FunctionSource = args.get_kw_arg("f")?;
|
||||||
let meta = vec![args.source_range.into()];
|
|
||||||
let new_array = inner_map(array, f, exec_state, &args).await?;
|
let new_array = inner_map(array, f, exec_state, &args).await?;
|
||||||
Ok(KclValue::MixedArray { value: new_array, meta })
|
Ok(KclValue::HomArray {
|
||||||
|
value: new_array,
|
||||||
|
ty: RuntimeType::any(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Apply a function to every element of a list.
|
/// Apply a function to every element of a list.
|
||||||
@ -257,6 +260,31 @@ async fn call_reduce_closure(
|
|||||||
Ok(out)
|
Ok(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn push(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||||
|
let array = args.get_unlabeled_kw_arg("array")?;
|
||||||
|
let item: KclValue = args.get_kw_arg("item")?;
|
||||||
|
|
||||||
|
let KclValue::HomArray { value: values, ty } = array else {
|
||||||
|
let meta = vec![args.source_range];
|
||||||
|
let actual_type = array.human_friendly_type();
|
||||||
|
return Err(KclError::Semantic(KclErrorDetails {
|
||||||
|
source_ranges: meta,
|
||||||
|
message: format!("You can't push to a value of type {actual_type}, only an array"),
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
let ty = if item.has_type(&ty) {
|
||||||
|
ty
|
||||||
|
} else {
|
||||||
|
// The user pushed an item with a type that differs from the array's
|
||||||
|
// element type.
|
||||||
|
RuntimeType::any()
|
||||||
|
};
|
||||||
|
|
||||||
|
let new_array = inner_push(values, item);
|
||||||
|
|
||||||
|
Ok(KclValue::HomArray { value: new_array, ty })
|
||||||
|
}
|
||||||
|
|
||||||
/// Append an element to the end of an array.
|
/// Append an element to the end of an array.
|
||||||
///
|
///
|
||||||
/// Returns a new array with the element appended.
|
/// Returns a new array with the element appended.
|
||||||
@ -276,28 +304,26 @@ async fn call_reduce_closure(
|
|||||||
},
|
},
|
||||||
tags = ["array"]
|
tags = ["array"]
|
||||||
}]
|
}]
|
||||||
async fn inner_push(mut array: Vec<KclValue>, item: KclValue, args: &Args) -> Result<KclValue, KclError> {
|
fn inner_push(mut array: Vec<KclValue>, item: KclValue) -> Vec<KclValue> {
|
||||||
array.push(item);
|
array.push(item);
|
||||||
Ok(KclValue::MixedArray {
|
|
||||||
value: array,
|
array
|
||||||
meta: vec![args.source_range.into()],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn push(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
pub async fn pop(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||||
// Extract the array and the element from the arguments
|
let array = args.get_unlabeled_kw_arg("array")?;
|
||||||
let val: KclValue = args.get_unlabeled_kw_arg("array")?;
|
let KclValue::HomArray { value: values, ty } = array else {
|
||||||
let item = args.get_kw_arg("item")?;
|
|
||||||
|
|
||||||
let meta = vec![args.source_range];
|
let meta = vec![args.source_range];
|
||||||
let KclValue::MixedArray { value: array, meta: _ } = val else {
|
let actual_type = array.human_friendly_type();
|
||||||
let actual_type = val.human_friendly_type();
|
|
||||||
return Err(KclError::Semantic(KclErrorDetails {
|
return Err(KclError::Semantic(KclErrorDetails {
|
||||||
source_ranges: meta,
|
source_ranges: meta,
|
||||||
message: format!("You can't push to a value of type {actual_type}, only an array"),
|
message: format!("You can't pop from a value of type {actual_type}, only an array"),
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
inner_push(array, item, &args).await
|
|
||||||
|
let new_array = inner_pop(values, &args)?;
|
||||||
|
|
||||||
|
Ok(KclValue::HomArray { value: new_array, ty })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove the last element from an array.
|
/// Remove the last element from an array.
|
||||||
@ -320,7 +346,7 @@ pub async fn push(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
|||||||
},
|
},
|
||||||
tags = ["array"]
|
tags = ["array"]
|
||||||
}]
|
}]
|
||||||
async fn inner_pop(array: Vec<KclValue>, args: &Args) -> Result<KclValue, KclError> {
|
fn inner_pop(array: Vec<KclValue>, args: &Args) -> Result<Vec<KclValue>, KclError> {
|
||||||
if array.is_empty() {
|
if array.is_empty() {
|
||||||
return Err(KclError::Semantic(KclErrorDetails {
|
return Err(KclError::Semantic(KclErrorDetails {
|
||||||
message: "Cannot pop from an empty array".to_string(),
|
message: "Cannot pop from an empty array".to_string(),
|
||||||
@ -331,24 +357,5 @@ async fn inner_pop(array: Vec<KclValue>, args: &Args) -> Result<KclValue, KclErr
|
|||||||
// Create a new array with all elements except the last one
|
// Create a new array with all elements except the last one
|
||||||
let new_array = array[..array.len() - 1].to_vec();
|
let new_array = array[..array.len() - 1].to_vec();
|
||||||
|
|
||||||
Ok(KclValue::MixedArray {
|
Ok(new_array)
|
||||||
value: new_array,
|
|
||||||
meta: vec![args.source_range.into()],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn pop(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
|
||||||
// Extract the array from the arguments
|
|
||||||
let val = args.get_unlabeled_kw_arg("array")?;
|
|
||||||
|
|
||||||
let meta = vec![args.source_range];
|
|
||||||
let KclValue::MixedArray { value: array, meta: _ } = val else {
|
|
||||||
let actual_type = val.human_friendly_type();
|
|
||||||
return Err(KclError::Semantic(KclErrorDetails {
|
|
||||||
source_ranges: meta,
|
|
||||||
message: format!("You can't pop from a value of type {actual_type}, only an array"),
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
inner_pop(array, &args).await
|
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,7 @@ async fn make_transform<T: GeometryTrait>(
|
|||||||
})?;
|
})?;
|
||||||
let transforms = match transform_fn_return {
|
let transforms = match transform_fn_return {
|
||||||
KclValue::Object { value, meta: _ } => vec![value],
|
KclValue::Object { value, meta: _ } => vec![value],
|
||||||
KclValue::MixedArray { value, meta: _ } => {
|
KclValue::Tuple { value, .. } | KclValue::HomArray { value, .. } => {
|
||||||
let transforms: Vec<_> = value
|
let transforms: Vec<_> = value
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|val| {
|
.map(|val| {
|
||||||
@ -671,12 +671,44 @@ impl GeometryTrait for Solid {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::execution::types::NumericType;
|
use crate::execution::types::{NumericType, PrimitiveType};
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_array_to_point3d() {
|
async fn test_array_to_point3d() {
|
||||||
let mut exec_state = ExecState::new(&ExecutorContext::new_mock().await);
|
let mut exec_state = ExecState::new(&ExecutorContext::new_mock().await);
|
||||||
let input = KclValue::MixedArray {
|
let input = KclValue::HomArray {
|
||||||
|
value: vec![
|
||||||
|
KclValue::Number {
|
||||||
|
value: 1.1,
|
||||||
|
meta: Default::default(),
|
||||||
|
ty: NumericType::mm(),
|
||||||
|
},
|
||||||
|
KclValue::Number {
|
||||||
|
value: 2.2,
|
||||||
|
meta: Default::default(),
|
||||||
|
ty: NumericType::mm(),
|
||||||
|
},
|
||||||
|
KclValue::Number {
|
||||||
|
value: 3.3,
|
||||||
|
meta: Default::default(),
|
||||||
|
ty: NumericType::mm(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::mm())),
|
||||||
|
};
|
||||||
|
let expected = [
|
||||||
|
TyF64::new(1.1, NumericType::mm()),
|
||||||
|
TyF64::new(2.2, NumericType::mm()),
|
||||||
|
TyF64::new(3.3, NumericType::mm()),
|
||||||
|
];
|
||||||
|
let actual = array_to_point3d(&input, Vec::new(), &mut exec_state);
|
||||||
|
assert_eq!(actual.unwrap(), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_tuple_to_point3d() {
|
||||||
|
let mut exec_state = ExecState::new(&ExecutorContext::new_mock().await);
|
||||||
|
let input = KclValue::Tuple {
|
||||||
value: vec![
|
value: vec![
|
||||||
KclValue::Number {
|
KclValue::Number {
|
||||||
value: 1.1,
|
value: 1.1,
|
||||||
|
@ -17,9 +17,9 @@ use crate::{
|
|||||||
/// Returns the point at the end of the given segment.
|
/// Returns the point at the end of the given segment.
|
||||||
pub async fn segment_end(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
pub async fn segment_end(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||||
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag")?;
|
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag")?;
|
||||||
let result = inner_segment_end(&tag, exec_state, args.clone())?;
|
let pt = inner_segment_end(&tag, exec_state, args.clone())?;
|
||||||
|
|
||||||
args.make_user_val_from_point(result)
|
args.make_kcl_val_from_point([pt[0].n, pt[1].n], pt[0].ty.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compute the ending point of the provided line segment.
|
/// Compute the ending point of the provided line segment.
|
||||||
@ -64,8 +64,11 @@ fn inner_segment_end(tag: &TagIdentifier, exec_state: &mut ExecState, args: Args
|
|||||||
source_ranges: vec![args.source_range],
|
source_ranges: vec![args.source_range],
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
let (p, ty) = path.end_point_components();
|
||||||
|
// Docs generation isn't smart enough to handle ([f64; 2], NumericType).
|
||||||
|
let point = [TyF64::new(p[0], ty.clone()), TyF64::new(p[1], ty)];
|
||||||
|
|
||||||
Ok(path.get_to().clone())
|
Ok(point)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the segment end of x.
|
/// Returns the segment end of x.
|
||||||
@ -156,9 +159,9 @@ fn inner_segment_end_y(tag: &TagIdentifier, exec_state: &mut ExecState, args: Ar
|
|||||||
/// Returns the point at the start of the given segment.
|
/// Returns the point at the start of the given segment.
|
||||||
pub async fn segment_start(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
pub async fn segment_start(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||||
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag")?;
|
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag")?;
|
||||||
let result = inner_segment_start(&tag, exec_state, args.clone())?;
|
let pt = inner_segment_start(&tag, exec_state, args.clone())?;
|
||||||
|
|
||||||
args.make_user_val_from_point(result)
|
args.make_kcl_val_from_point([pt[0].n, pt[1].n], pt[0].ty.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compute the starting point of the provided line segment.
|
/// Compute the starting point of the provided line segment.
|
||||||
@ -203,8 +206,11 @@ fn inner_segment_start(tag: &TagIdentifier, exec_state: &mut ExecState, args: Ar
|
|||||||
source_ranges: vec![args.source_range],
|
source_ranges: vec![args.source_range],
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
let (p, ty) = path.start_point_components();
|
||||||
|
// Docs generation isn't smart enough to handle ([f64; 2], NumericType).
|
||||||
|
let point = [TyF64::new(p[0], ty.clone()), TyF64::new(p[1], ty)];
|
||||||
|
|
||||||
Ok(path.get_from().to_owned())
|
Ok(point)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the segment start of x.
|
/// Returns the segment start of x.
|
||||||
|
32
rust/kcl-lib/tests/any_type/artifact_commands.snap
Normal file
32
rust/kcl-lib/tests/any_type/artifact_commands.snap
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
source: kcl-lib/src/simulation_tests.rs
|
||||||
|
description: Artifact graph flowchart any_type.kcl
|
||||||
|
extension: md
|
||||||
|
snapshot_kind: binary
|
||||||
|
---
|
@ -0,0 +1,3 @@
|
|||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
```
|
921
rust/kcl-lib/tests/any_type/ast.snap
Normal file
921
rust/kcl-lib/tests/any_type/ast.snap
Normal 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
|
||||||
|
}
|
||||||
|
}
|
32
rust/kcl-lib/tests/any_type/input.kcl
Normal file
32
rust/kcl-lib/tests/any_type/input.kcl
Normal 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)
|
||||||
|
|
184
rust/kcl-lib/tests/any_type/ops.snap
Normal file
184
rust/kcl-lib/tests/any_type/ops.snap
Normal 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"
|
||||||
|
}
|
||||||
|
]
|
69
rust/kcl-lib/tests/any_type/program_memory.snap
Normal file
69
rust/kcl-lib/tests/any_type/program_memory.snap
Normal 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
|
||||||
|
}
|
||||||
|
}
|
35
rust/kcl-lib/tests/any_type/unparsed.snap
Normal file
35
rust/kcl-lib/tests/any_type/unparsed.snap
Normal 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)
|
@ -4,7 +4,7 @@ description: Variables in memory after executing array_elem_pop.kcl
|
|||||||
---
|
---
|
||||||
{
|
{
|
||||||
"arr": {
|
"arr": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -48,7 +48,7 @@ description: Variables in memory after executing array_elem_pop.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"new_arr1": {
|
"new_arr1": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -79,7 +79,7 @@ description: Variables in memory after executing array_elem_pop.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"new_arr2": {
|
"new_arr2": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -97,7 +97,7 @@ description: Variables in memory after executing array_elem_pop.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"new_arr3": {
|
"new_arr3": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": []
|
"value": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ description: Variables in memory after executing array_elem_push.kcl
|
|||||||
---
|
---
|
||||||
{
|
{
|
||||||
"arr": {
|
"arr": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -48,7 +48,7 @@ description: Variables in memory after executing array_elem_push.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"new_arr1": {
|
"new_arr1": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -105,7 +105,7 @@ description: Variables in memory after executing array_elem_push.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"new_arr2": {
|
"new_arr2": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -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
|
||||||
|
---
|
@ -0,0 +1,3 @@
|
|||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
```
|
269
rust/kcl-lib/tests/array_push_item_wrong_type/ast.snap
Normal file
269
rust/kcl-lib/tests/array_push_item_wrong_type/ast.snap
Normal 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
|
||||||
|
}
|
||||||
|
}
|
3
rust/kcl-lib/tests/array_push_item_wrong_type/input.kcl
Normal file
3
rust/kcl-lib/tests/array_push_item_wrong_type/input.kcl
Normal 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")
|
5
rust/kcl-lib/tests/array_push_item_wrong_type/ops.snap
Normal file
5
rust/kcl-lib/tests/array_push_item_wrong_type/ops.snap
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
source: kcl-lib/src/simulation_tests.rs
|
||||||
|
description: Operations executed array_push_item_wrong_type.kcl
|
||||||
|
---
|
||||||
|
[]
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -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")
|
@ -30,7 +30,7 @@ description: Variables in memory after executing array_range_expr.kcl
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"r1": {
|
"r1": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -75,7 +75,7 @@ description: Variables in memory after executing array_range_expr.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"r2": {
|
"r2": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -120,7 +120,7 @@ description: Variables in memory after executing array_range_expr.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"r3": {
|
"r3": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -173,7 +173,7 @@ description: Variables in memory after executing array_range_expr.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"r4": {
|
"r4": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -4,7 +4,7 @@ description: Variables in memory after executing array_range_negative_expr.kcl
|
|||||||
---
|
---
|
||||||
{
|
{
|
||||||
"xs": {
|
"xs": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -4,7 +4,7 @@ description: Variables in memory after executing computed_var.kcl
|
|||||||
---
|
---
|
||||||
{
|
{
|
||||||
"arr": {
|
"arr": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -8,7 +8,7 @@ description: Variables in memory after executing double_map_fn.kcl
|
|||||||
"value": null
|
"value": null
|
||||||
},
|
},
|
||||||
"xs": {
|
"xs": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -37,7 +37,7 @@ description: Variables in memory after executing double_map_fn.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ys": {
|
"ys": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -614,7 +614,7 @@ description: Variables in memory after executing i_shape.kcl
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"d_wrist_circumference": {
|
"d_wrist_circumference": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -17,7 +17,7 @@ description: Variables in memory after executing import_async.kcl
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"angles": {
|
"angles": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -1126,7 +1126,7 @@ description: Variables in memory after executing import_async.kcl
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"invas": {
|
"invas": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2268,7 +2268,7 @@ description: Variables in memory after executing import_async.kcl
|
|||||||
"value": null
|
"value": null
|
||||||
},
|
},
|
||||||
"rs": {
|
"rs": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -86833,7 +86833,7 @@ description: Variables in memory after executing import_async.kcl
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"xs": {
|
"xs": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -88164,7 +88164,7 @@ description: Variables in memory after executing import_async.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ys": {
|
"ys": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -4,7 +4,7 @@ description: Variables in memory after executing index_of_array.kcl
|
|||||||
---
|
---
|
||||||
{
|
{
|
||||||
"arr": {
|
"arr": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -29,7 +29,7 @@ description: Variables in memory after executing dodecahedron.kcl
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dodecFaces": {
|
"dodecFaces": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Solid",
|
"type": "Solid",
|
||||||
@ -2194,10 +2194,10 @@ description: Variables in memory after executing dodecahedron.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"faceRotations": {
|
"faceRotations": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2254,7 +2254,7 @@ description: Variables in memory after executing dodecahedron.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2311,7 +2311,7 @@ description: Variables in memory after executing dodecahedron.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2368,7 +2368,7 @@ description: Variables in memory after executing dodecahedron.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2425,7 +2425,7 @@ description: Variables in memory after executing dodecahedron.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2482,7 +2482,7 @@ description: Variables in memory after executing dodecahedron.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2539,7 +2539,7 @@ description: Variables in memory after executing dodecahedron.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2596,7 +2596,7 @@ description: Variables in memory after executing dodecahedron.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2653,7 +2653,7 @@ description: Variables in memory after executing dodecahedron.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2710,7 +2710,7 @@ description: Variables in memory after executing dodecahedron.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2767,7 +2767,7 @@ description: Variables in memory after executing dodecahedron.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2824,7 +2824,7 @@ description: Variables in memory after executing dodecahedron.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -2018,7 +2018,7 @@ description: Variables in memory after executing food-service-spatula.kcl
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2062,7 +2062,7 @@ description: Variables in memory after executing food-service-spatula.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"xAxis": {
|
"xAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2106,7 +2106,7 @@ description: Variables in memory after executing food-service-spatula.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"yAxis": {
|
"yAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2150,7 +2150,7 @@ description: Variables in memory after executing food-service-spatula.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"zAxis": {
|
"zAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -4190,7 +4190,7 @@ description: Variables in memory after executing french-press.kcl
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -4234,7 +4234,7 @@ description: Variables in memory after executing french-press.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"xAxis": {
|
"xAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -4278,7 +4278,7 @@ description: Variables in memory after executing french-press.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"yAxis": {
|
"yAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -4322,7 +4322,7 @@ description: Variables in memory after executing french-press.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"zAxis": {
|
"zAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -17,7 +17,7 @@ description: Variables in memory after executing gear.kcl
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"angles": {
|
"angles": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -1126,7 +1126,7 @@ description: Variables in memory after executing gear.kcl
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"invas": {
|
"invas": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -2261,7 +2261,7 @@ description: Variables in memory after executing gear.kcl
|
|||||||
"value": null
|
"value": null
|
||||||
},
|
},
|
||||||
"rs": {
|
"rs": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -86790,7 +86790,7 @@ description: Variables in memory after executing gear.kcl
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"xs": {
|
"xs": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -88121,7 +88121,7 @@ description: Variables in memory after executing gear.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ys": {
|
"ys": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -7,7 +7,7 @@ description: Variables in memory after executing gridfinity-baseplate-magnets.kc
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"direction": {
|
"direction": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -38,7 +38,7 @@ description: Variables in memory after executing gridfinity-baseplate-magnets.kc
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -7,7 +7,7 @@ description: Variables in memory after executing gridfinity-baseplate.kcl
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"direction": {
|
"direction": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -38,7 +38,7 @@ description: Variables in memory after executing gridfinity-baseplate.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -12,7 +12,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"direction": {
|
"direction": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -43,7 +43,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -79,7 +79,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"direction": {
|
"direction": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -110,7 +110,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -20212,7 +20212,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -20256,7 +20256,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"xAxis": {
|
"xAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -20300,7 +20300,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"yAxis": {
|
"yAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -20349,7 +20349,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -20393,7 +20393,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"xAxis": {
|
"xAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -20437,7 +20437,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"yAxis": {
|
"yAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -20486,7 +20486,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -20530,7 +20530,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"xAxis": {
|
"xAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -20574,7 +20574,7 @@ description: Variables in memory after executing gridfinity-bins-stacking-lip.kc
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"yAxis": {
|
"yAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -7,7 +7,7 @@ description: Variables in memory after executing gridfinity-bins.kcl
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"direction": {
|
"direction": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -38,7 +38,7 @@ description: Variables in memory after executing gridfinity-bins.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -53,7 +53,7 @@ description: Variables in memory after executing keyboard.kcl
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -97,7 +97,7 @@ description: Variables in memory after executing keyboard.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"xAxis": {
|
"xAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -141,7 +141,7 @@ description: Variables in memory after executing keyboard.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"yAxis": {
|
"yAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -180,7 +180,7 @@ description: Variables in memory after executing keyboard.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"zAxis": {
|
"zAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -229,7 +229,7 @@ description: Variables in memory after executing keyboard.kcl
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -273,7 +273,7 @@ description: Variables in memory after executing keyboard.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"xAxis": {
|
"xAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -317,7 +317,7 @@ description: Variables in memory after executing keyboard.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"yAxis": {
|
"yAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -356,7 +356,7 @@ description: Variables in memory after executing keyboard.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"zAxis": {
|
"zAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -569,7 +569,7 @@ description: Variables in memory after executing subtract_regression03.kcl
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -613,7 +613,7 @@ description: Variables in memory after executing subtract_regression03.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"xAxis": {
|
"xAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -657,7 +657,7 @@ description: Variables in memory after executing subtract_regression03.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"yAxis": {
|
"yAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -701,7 +701,7 @@ description: Variables in memory after executing subtract_regression03.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"zAxis": {
|
"zAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -750,7 +750,7 @@ description: Variables in memory after executing subtract_regression03.kcl
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -794,7 +794,7 @@ description: Variables in memory after executing subtract_regression03.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"xAxis": {
|
"xAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -838,7 +838,7 @@ description: Variables in memory after executing subtract_regression03.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"yAxis": {
|
"yAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -882,7 +882,7 @@ description: Variables in memory after executing subtract_regression03.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"zAxis": {
|
"zAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -931,7 +931,7 @@ description: Variables in memory after executing subtract_regression03.kcl
|
|||||||
"type": "Object",
|
"type": "Object",
|
||||||
"value": {
|
"value": {
|
||||||
"origin": {
|
"origin": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -975,7 +975,7 @@ description: Variables in memory after executing subtract_regression03.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"xAxis": {
|
"xAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -1019,7 +1019,7 @@ description: Variables in memory after executing subtract_regression03.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"yAxis": {
|
"yAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
@ -1063,7 +1063,7 @@ description: Variables in memory after executing subtract_regression03.kcl
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"zAxis": {
|
"zAxis": {
|
||||||
"type": "MixedArray",
|
"type": "HomArray",
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
|
@ -238,7 +238,7 @@ newVar = myVar + 1`
|
|||||||
ty: expect.any(Object),
|
ty: expect.any(Object),
|
||||||
})
|
})
|
||||||
expect(mem['yo']).toEqual({
|
expect(mem['yo']).toEqual({
|
||||||
type: 'MixedArray',
|
type: 'HomArray',
|
||||||
value: [
|
value: [
|
||||||
{
|
{
|
||||||
type: 'Number',
|
type: 'Number',
|
||||||
|
Reference in New Issue
Block a user