IDE: Fire
Version: Version 10.0.0.2400 (develop) built on talax, 20190429-101133. Commit 7d23006
Target (If relevant): iOS
Description:
I have found this code snippet in an existing (Xcode) project and I noticed it’s not compiling in Silver. I am trying to create tupple of two enums and check the values in switch
-statement like this:
/// Represents the state of the view state machine
public enum ViewStateMachineState : Equatable {
case none // No view shown
case view(String) // View with specific key is shown
}
public func == (lhs: ViewStateMachineState, rhs: ViewStateMachineState) -> Bool {
switch (lhs, rhs) {
case (.none, .none): return true
case (.view(let lName), .view(let rName)): return lName == rName
default: return false
}
}
Expected Behavior:
Allow to compile this code and check the values of an (inline?) topple within a switch
-statement
Actual Behavior:
The compiler is throwing the following errors instead:
E: Syntax error [/Users/x/Documents/App3/RootViewController.swift (12)]
E: comma or closing parenthesis expected, got "let" [/Users/x/Documents/App3/RootViewController.swift (12)]
E: Syntax error [/Users/x/Documents/App3/RootViewController.swift (12)]
E: comma or closing parenthesis expected, got "let" [/Users/x/Documents/App3/RootViewController.swift (12)]
Reference: /Users/x/Development/Compilers/10.0.0.2400-20190426-15560/Toffee SDKs/iOS 12.2 Simulator/CoreFoundation.fx (implicit)
-> Phase Resolving Bodies started.
Reference: /Users/x/Development/Compilers/10.0.0.2400-20190426-15560/Toffee SDKs/iOS 12.2 Simulator/CloudKit.fx
E: Tuple expected for expression [/Users/x/Documents/App3/RootViewController.swift (11)]
E: Tuple expected for expression [/Users/x/Documents/App3/RootViewController.swift (12)]
E: Unknown identifier "lName" [/Users/x/Documents/App3/RootViewController.swift (12)]
Reference: /Users/x/Development/Compilers/10.0.0.2400-20190426-15560/Toffee SDKs/iOS 12.2 Simulator/CoreLocation.fx
E: Unknown identifier "rName" [/Users/x/Documents/App3/RootViewController.swift (12)]
<- Phase Resolving Bodies finished, took 1.0034s.
-> Phase Checking Members started.
<- Phase Checking Members finished, took 0.0608s.
-> Phase Generating Helper Types started.
E: Member "<special>.view" of type "<unknown type>" is a variable but is used as a method [/Users/x/Documents/App3/RootViewController.swift (12)]
E: Member "<special>.view" of type "<unknown type>" is a variable but is used as a method [/Users/x/Documents/App3/RootViewController.swift (12)]
<- Phase Generating Helper Types failed.
Steps:
Step 1 Create a simple iOS application
Step 2 Copy code below in ViewController.swift
Step 3 Try to compile
import UIKit
/// Represents the state of the view state machine
public enum ViewStateMachineState : Equatable {
case none // No view shown
case view(String) // View with specific key is shown
}
public func == (lhs: ViewStateMachineState, rhs: ViewStateMachineState) -> Bool {
switch (lhs, rhs) {
case (.none, .none): return true
case (.view(let lName), .view(let rName)): return lName == rName
default: return false
}
}
@IBObject class RootViewController : UIViewController {
var currentState: String?
//let color: UIColor = .clear
public override func viewDidLoad() {
super.viewDidLoad()
}
public override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}