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-13232] Property wrappers: $projectedValue syntax chokes on non-ASCII characters #55672

Closed
ole opened this issue Jul 16, 2020 · 4 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself parser Area → compiler: The legacy C++ parser property wrappers Feature: property wrappers

Comments

@ole
Copy link
Contributor

ole commented Jul 16, 2020

Previous ID SR-13232
Radar None
Original Reporter @ole
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Tested in Xcode 12.0 beta 2 (Swift 5.3) and Xcode 11.5 (Swift 5.2.4).

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Parser, PropertyWrappers
Assignee @theblixguy
Priority Medium

md5: dcf92c5bd51f756e2d49a1e2a2c52ace

is duplicated by:

  • SR-14094 Projected value's name is parsed incorrectly if it contains non-ASCII characters

Issue Description:

The last line of this snippet doesn't compile:

@propertyWrapper
struct Wrapper {
  var wrappedValue: Int
  var projectedValue: String {
    String(wrappedValue)
  }
}

struct S {
  @Wrapper var café = 42
}

S().$café // parse/lex error here

Errors:

non-ascii.swift:14:9: error: consecutive statements on a line must be separated by ';'
S().$café
non-ascii.swift:14:5: error: value of type 'S' has no member '$caf'
S().$café
non-ascii.swift:14:9: error: cannot find 'é' in scope
S().$café

It looks like the $projectedValue syntax can't handle non-ASCII characters in the identifier. I tried wrapping it in backticks like this: `$café` or like this: $`café`. But it still doesn't compile.

Changing the variable name to cafe works, of course.

I tried this with several identifiers with non-ASCII characters and/or emoji, always with the same result.

@theblixguy
Copy link
Collaborator

Here's a fix: #32961

@theblixguy
Copy link
Collaborator

Fixed on master. Please verify using the next available snapshot!

@ole
Copy link
Contributor Author

ole commented Jul 21, 2020

@theblixguy Thank you so much for the superfast fix. I will check with the next master snapshot (there doesn't seem to be a newer one than 17 July yet).

@ole
Copy link
Contributor Author

ole commented Jul 22, 2020

Fix confirmed with DEVELOPMENT-SNAPSHOT-2020-07-21-a on macOS. Thanks again @theblixguy!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself parser Area → compiler: The legacy C++ parser property wrappers Feature: property wrappers
Projects
None yet
Development

No branches or pull requests

2 participants