You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dante-Broggi opened this issue
Feb 4, 2018
· 3 comments
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfparserArea → compiler: The legacy C++ parser
This code should not compile, because these string literals should not have beginning quote characters:
```swift
let quote = "̠"
```
`{LATIN SMALL LETTER L}{LATIN SMALL LETTER E}{LATIN SMALL LETTER T}{SPACE}{LATIN SMALL LETTER Q}{LATIN SMALL LETTER U}{LATIN SMALL LETTER O}{LATIN SMALL LETTER T}{LATIN SMALL LETTER E}{SPACE}{EQUALS SIGN}{SPACE}{QUOTATION MARK}{COMBINING MINUS SIGN BELOW}{QUOTATION MARK}
`
To verify this, let us ask what swift strings think:
@akyrtzi, @rintaro, what do you think we should do here? I feel like we should probably just close this. Handling it properly would mean consulting a Unicode table in the OS, which would slow down lexing.
#include"swift/Basic/Unicode.h"usingswift::unicode;
/// Returns true if a quote followed by 'scalarAfterQuote' can be used as a quote.boolisValidQuote(uint32_tscalarAfterQuote) {
if (scalarAfterQuote < 0x80)
returntrue;
autoGCBForQuoteMark = getGraphemeClusterBreakProperty('"');
autoGCBForFirstScalar = getGraphemeClusterBreakProperty(scalarAfterQuote);
// If 'scalarAfterQuote' is a EGC boundary, it's a valid quote.returnisExtendedGraphemeClusterBoundary(GCBForQuoteMark, GCBForFirstScalar);
}
// Check isValidQuote() for each quotes in string literal (and start quote)
If we implement this, the following code should be valid.
let a = "foo "̠ bar"
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfparserArea → compiler: The legacy C++ parser
Additional Detail from JIRA
md5: 493f3295b28807d82094414006ece57b
Issue Description:
This code should not compile, because these string literals should not have beginning quote characters:
```swift
let quote = "̠"
```
`{LATIN SMALL LETTER L}{LATIN SMALL LETTER E}{LATIN SMALL LETTER T}{SPACE}{LATIN SMALL LETTER Q}{LATIN SMALL LETTER U}{LATIN SMALL LETTER O}{LATIN SMALL LETTER T}{LATIN SMALL LETTER E}{SPACE}{EQUALS SIGN}{SPACE}{QUOTATION MARK}{COMBINING MINUS SIGN BELOW}{QUOTATION MARK}
`
To verify this, let us ask what swift strings think:
```swift
let quoteCount = """
```
The above returns that there is 1 quote, meaning it cannot be a valid string literal, yet it is.
The text was updated successfully, but these errors were encountered: