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-10011] [Lexer] Raw Strings escape character sequence resembling multiline delimiter #34414

Merged
merged 6 commits into from
Oct 27, 2020

Conversation

maustinstar
Copy link
Contributor

@maustinstar maustinstar commented Oct 23, 2020

Summary

The Lexer currently treats triple-quotes as a multiline delimiter for Strings. This PR allows the multiline delimiter (""") to be escaped in raw Strings when a valid closing custom delimiter (e.g. #) is found before a newline.

Problem

The Lexer does not register some strings that are technically valid according to the documented regex on string literals.

For example: #"""#
Gives the errors: Multi-line string literal content must begin on a new line & Unterminated string literal

Impact

This change does not impact any Strings that are already valid, rather, this PR enables a new set of String literals to be considered valid.

After merging this PR:
#"""# is now equivalent to "\""
#"""text"# equates to "\"\"text"
#""" is still the beginning of a multiline raw string.

Links

Resolves SR-10011.
Replaces my previous PR attempt: #23115

Tagging @rintaro and @xwu from activity in my previous PR #23115.

test/Parse/raw_string.swift Outdated Show resolved Hide resolved
test/Parse/raw_string.swift Outdated Show resolved Hide resolved
Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>
@rintaro rintaro self-assigned this Oct 26, 2020
@rintaro
Copy link
Member

rintaro commented Oct 26, 2020

@swift-ci Please smoke test

@maustinstar
Copy link
Contributor Author

Error from the CI:

/Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-main/swift/test/Interop/Cxx/templates/class-template-variadic.swift:17:18: error: missing arguments for parameters #1, #2 in call
14:46:22   var pair = Pair()
14:46:22                  ^
14:46:22                   <#IntWrapper#>, <#IntWrapper#>
14:46:22 ClassTemplateVariadic.__CxxTemplateInst5TupleIJ10IntWrapperS0_EE:3:12: note: 'init(_:_:)' declared here
14:46:22     public init(_ t: IntWrapper, _ ts: IntWrapper)
14:46:22            ^
14:46:22 
14:46:22 --

This doesn't seem to be related to my PR. On my machine, the compiler builds and passes all tests using ninja. Did a recent merge break the compiler? Or, is this from my PR?

@xwu
Copy link
Collaborator

xwu commented Oct 26, 2020

A recent merge; should be reverted now. Let's try again:

@swift-ci Please smoke test

@rintaro
Copy link
Member

rintaro commented Oct 27, 2020

@swift-ci Please test Windows

1 similar comment
@rintaro
Copy link
Member

rintaro commented Oct 27, 2020

@swift-ci Please test Windows

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants