Files
regorus/tests/interpreter/cases/some/tests.yaml
Anand Krishnamoorthi 1e4ff952e6 feat!: Introduce structured destructuring plans for bindings (#485)
- add a dedicated `compiler/destructuring_planner` feature that precomputes binding plans for assignments, parameters, and `some in` expressions
- enrich `ScopeContext` with same-scope tracking, local scheduling hints, and module globals so the planner enforces := shadowing rules without blocking parent scopes
- wire the planner through compiler, hoist, interpreter, and engine paths while updating binding plan variants and adding query traversal helpers for dependency analysis
- document the new planner architecture and ship interpreter regressions that exercise nested destructuring, shadowing, and error reporting

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2025-10-21 15:57:49 -05:00

117 lines
2.6 KiB
YAML

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
cases:
- note: array
data: {}
modules:
- |
package test
import future.keywords
r1 = y {
# value
y1 = [x | some x in [1, 2, 3]; x >= 2]
# key and value
y2 = [y | some x, y in [1, 2, 3]; x >= 2]
y = [y1, y2]
}
r2[x] {
# Constant value
some x, "l" in ["h", "e", "l", "l", "o"]
}
r3[x] {
# Constant value
some 1, x in ["h", "e", "l", "l", "o"]
}
r4[x] {
# Extract array element
some [5, x] in [[0, 1], [5, 1], [5, 2]]
}
r5[x+y] {
# Extract multiple array elements
some [5, x, y, 9] in [[0, 1], [5, 1, 2, 9], [5, 2, 8, 9]]
}
# Undefined
r6 {
some x in []
}
r7 {
some x in r6
}
query: data.test
want_result:
r1: [ [2, 3], [3]]
r2:
set!: [2, 3]
r3:
set!: ["e"]
r4:
set!: [1, 2]
r5:
set!: [3, 10]
- note: type-mismatch
data: {}
modules:
- |
package test
import future.keywords
x { some [1] in [1] }
query: data.test
error: "Cannot bind pattern of type `array`"
# TODO: How to raise errors only for static mismatches.
skip: true
- note: array-length-mismatch
data: {}
modules:
- |
package test
import future.keywords
x { some [1] in [[1, 2]] }
query: data.test
error: "mismatch in number of array elements"
- note: array-length-mismatch-skipped
data: {}
modules:
- |
package test
import future.keywords
x { some [1] in [[1, 2], [1]] }
query: data.test
want_result:
x: true
- note: invalid-null
data: {}
modules: ["package test\nimport future.keywords\nx { some _ in null}"]
query: data.test
error: "`some .. in collection` expects array/set/object."
- note: invalid-bool
data: {}
modules: ["package test\nimport future.keywords\nx { some _ in false}"]
query: data.test
error: "`some .. in collection` expects array/set/object."
- note: invalid-number
data: {}
modules: ["package test\nimport future.keywords\nx { some _ in 0}"]
query: data.test
error: "`some .. in collection` expects array/set/object."
- note: invalid-string
data: {}
modules: ["package test\nimport future.keywords\nx { some _ in \"\"}"]
query: data.test
error: "`some .. in collection` expects array/set/object."