Failing to build syntax tree from raw string
Closed this issue · 1 comments
rex-remind101 commented
Issue Kind
None
Source Code
I tried to follow this documentation https://github.com/apple/swift-syntax/blob/main/Sources/SwiftSyntax/Documentation.docc/Working%20with%20SwiftSyntax.md#building-syntax-trees
In my Package.swift
:
.package(url: "https://github.com/apple/swift-syntax", exact: "508.0.0"),
...
dependencies: [
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftParser", package: "swift-syntax")
]),
...
In my code:
import SwiftSyntax
import SwiftParser
func createClass(named name: String) -> ClassDeclSyntax {
return """
class \(raw: name) {}
"""
}
Error received:
Cannot convert return expression of type 'String' to return type 'ClassDeclSyntax'
Description
First time user.
swift --version
swift-driver version: 1.75.2 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0
rex-remind101 commented
I see, this isn't in the latest release https://github.com/apple/swift-syntax/blob/508.0.1/Sources/SwiftSyntax/Documentation.docc/Working%20with%20SwiftSyntax.md