Skip to content

Commit 6398318

Browse files
committed
Fix regression in blocks returning a path
1 parent f9778b0 commit 6398318

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

ShapeScript/Interpreter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,8 @@ extension EvaluationContext {
935935
children.append(.point(v.transformed(by: childTransform)))
936936
case let .path(path):
937937
children.append(.path(path.transformed(by: childTransform)))
938-
case let .tuple(values) where values.isEmpty:
939-
break
938+
case let .tuple(values) where values.count <= 1:
939+
children += values
940940
default:
941941
children.append(value)
942942
}

ShapeScriptTests/InterpreterTests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,18 @@ class InterpreterTests: XCTestCase {
14011401
XCTAssertEqual(context.children.count, 1)
14021402
}
14031403

1404+
func testBlockReturningPathInsidePath() throws {
1405+
let program = try parse("""
1406+
define foo path {
1407+
point 0 0
1408+
point 1 0
1409+
point 1 1
1410+
}
1411+
path { foo }
1412+
""")
1413+
XCTAssertNoThrow(try evaluate(program, delegate: nil))
1414+
}
1415+
14041416
// MARK: Ranges
14051417

14061418
func testRange() {

0 commit comments

Comments
 (0)