Fix to use correct units for array range expressions (#6837)

* Fix to use correct units for array range expressions

* Update output
This commit is contained in:
Jonathan Tran
2025-05-12 01:30:33 -04:00
committed by GitHub
parent 1240b23080
commit 1a325d0b29
26 changed files with 8766 additions and 2322 deletions

View File

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

View File

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

View File

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

View File

@ -0,0 +1,125 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Result of parsing array_range_mismatch_units.kcl
---
{
"Ok": {
"body": [
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "a",
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 0,
"end": 0,
"endElement": {
"commentStart": 0,
"end": 0,
"raw": "3cm",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.0,
"suffix": "Cm"
}
},
"endInclusive": true,
"start": 0,
"startElement": {
"commentStart": 0,
"end": 0,
"raw": "1mm",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "Mm"
}
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
},
"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": "error",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 0,
"end": 0,
"raw": "\"shouldn't make it here\"",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": "shouldn't make it here"
}
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "assertIs",
"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": "false",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": false
}
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"commentStart": 0,
"end": 0,
"start": 0
}
}

View File

@ -0,0 +1,14 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Error from executing array_range_mismatch_units.kcl
---
KCL Semantic error
× semantic: Range start and end must be of the same type, but found 1:
│ number(mm) and 3: number(cm)
╭─[1:5]
1 │ a = [1mm..3cm]
· ─────┬────
· ╰── tests/array_range_mismatch_units/input.kcl
2 │ assertIs(false, error = "shouldn't make it here")
╰────

View File

@ -0,0 +1,2 @@
a = [1mm..3cm]
assertIs(false, error = "shouldn't make it here")

View File

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

View File

@ -0,0 +1,6 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Result of unparsing array_range_mismatch_units.kcl
---
a = [1mm..3cm]
assertIs(false, error = "shouldn't make it here")