Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-10620] Raw strings literal is eliminated in StringInterpolationExpr #432

Closed
swift-ci opened this issue May 6, 2019 · 2 comments
Closed

Comments

@swift-ci
Copy link
Contributor

@swift-ci swift-ci commented May 6, 2019

Previous ID SR-10620
Radar rdar://problem/50492902
Original Reporter kitasuke (JIRA User)
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler, SwiftSyntax
Labels Improvement, Syntax
Assignee @jansvoboda11
Priority Medium

md5: 2bdc43d7872ae8b293a7b2cc41926345

Issue Description:

Overview

It seems like that `StringInterpolationExpr` doesn't have syntax info of raw strings literal(#). Is this expected behavior? If so, formatter/rewriter tools might have an issue because generated swift code from libSyntax/SwiftSyntax would be a bit different from input swift code.

Examples

As you can see below example, raw strings literal `#` is eliminated in syntax tree.

// sample.swift
#"foo \#(bar)"#
// swift -frontend -emit-syntax sample.swift
{"id":18,"kind":"SourceFile","layout":[{"id":17,"kind":"CodeBlockItemList","layout":[{"id":14,"kind":"CodeBlockItem","layout":[{"id":13,"kind":"StringInterpolationExpr","layout":[{"id":1,"tokenKind":{"kind":"string_quote"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"id":12,"kind":"StringInterpolationSegments","layout":[{"id":3,"kind":"StringSegment","layout":[{"id":2,"tokenKind":{"kind":"string_segment","text":"foo "},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"}],"presence":"Present"},{"id":9,"kind":"ExpressionSegment","layout":[{"id":4,"tokenKind":{"kind":"backslash"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"id":5,"tokenKind":{"kind":"l_paren"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"id":7,"kind":"IdentifierExpr","layout":[{"id":6,"tokenKind":{"kind":"identifier","text":"bar"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},null],"presence":"Present"},{"id":8,"tokenKind":{"kind":"string_interpolation_anchor"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"}],"presence":"Present"},{"id":11,"kind":"StringSegment","layout":[{"id":10,"tokenKind":{"kind":"string_segment","text":""},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"}],"presence":"Present"}],"presence":"Present"},{"id":1,"tokenKind":{"kind":"string_quote"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"}],"presence":"Present"},null,null],"presence":"Present"}],"presence":"Present"},{"id":16,"tokenKind":{"kind":"eof","text":""},"leadingTrivia":[{"kind":"Newline","value":1}],"trailingTrivia":[],"presence":"Present"}],"presence":"Present"}

Qestions

Can we have the raw strings literal as token kind like pound in syntax tree? This can be eliminated in AST as it is.

@rintaro
Copy link
Mannequin

@rintaro rintaro mannequin commented May 6, 2019

This is definitely not intentional. Thank you!

@jansvoboda11
Copy link
Member

@jansvoboda11 jansvoboda11 commented May 16, 2019

Resolved by apple/swift#24785.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants