Uploaded image for project: 'Swift'
  1. Swift
  2. SR-10024

Add new TokenKinds for contextual keyword in libSyntax/SwiftSyntax

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler, SwiftSyntax
    • Labels:
      None

      Description

      All contextual keyword's token kind is `identifier` for now, but I would like to have them as keyword kind instead.

      For example, I was expecting to have `weakKeyword` for below variable declaration, but I got `identifier("weak")` in SwiftSyntax. In this context, it can tell keyword, not identifier.

      Same thing happens to other contextual keywords as well.

       

      @IBOutlet private weak var button: UIButton!
      

       

      Sample code:

      // sample.swift
      class View {
       @IBOutlet private weak var button: UIButton!
      }
      
       $swiftc -frontend -emit-syntax sample.swift  
      

       

      Expected: 

      "tokenKind":{"kind":"kw_weak"

      Actual:

      "tokenKind":{"kind":"identifier","text":"weak"}
      

      Environment:

      Xcode 10.2 beta 3 (10P99q)

      Apple Swift version 5.0 (swiftlang-1001.0.63.8 clang-1001.0.43)
      Target: x86_64-apple-darwin18.2.0

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            kitasuke Yusuke Kita
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: