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
// In framework Module "Darwin"
public struct DarwinBoolean : BooleanType, BooleanLiteralConvertible {
public init(_ value: Bool)
/// Create an instance initialized to `value`.
public init(booleanLiteral value: Bool)
}
(3) compiler-control statement can appear in declaration
(4) "nonmutating?" or "declaration-modifier" needed before "set" in "setter-keyword-clause"
Grammar:
setter-keyword-clause:
- attributes? set
+ attributes? nonmutating? set
Example:
// In framework module "Swift"
public struct AutoreleasingUnsafeMutablePointer<Memory> : Equatable, NilLiteralConvertible, _PointerType {
...
public var memory: Memory { get nonmutating set }
...
}
(5) "nonmutating?" or "declaration-modifier" needed before "set" in "setter-clause"
Similar to (4)
(6) "attributes?" needed after "=" in "typealias-assignment"
Grammar:
typealias-assignment
- : = type
+ : = attributes? type
Example:
// In framework module "CFNetwork.CFHost"
public typealias CFHostClientCallBack = @convention(c) (CFHost, CFHostInfoType, UnsafePointer<CFStreamError>, UnsafeMutablePointer<Void>) -> Void
(7) "type-annotation" has to be optional in some rules of "parameter"
public class CC {
func kkk (lhs: Bool, @autoclosure rhs: () throws -> Bool) rethrows -> Bool {return true}
}
(9) "= default" in "default-argument-clause"
Grammar:
default_argument_clause:
+ | = default
Example:
// In framework module "Swift"
extension ContiguousArray : _ArrayType {
public mutating func removeAll(keepCapacity keepCapacity: Bool = default)
}
/*
* According to subsection "Keywords and Punctuation", "default" is a keyword and cannot be used as identifiers.
* So, "default" cannot be matched by the "expression" rule
*/
(10) "access-level-modifier" should be "declaration-modifiers" in "class-declaration"
public enum car{
case SUV
case UNKNOWN
public func printCar() {
switch self {
case SUV:
print("SUV")
case .SUV: // Warning: Case will never be executed
print("SUV-2")
default:
print("default")
}
}
}
According to a duplicate report via feedback assistant I believe this was fixed, but the grammar also changed a lot since then. Please let us know if we missed something.
Additional Detail from JIRA
md5: 39cca24b6ed0d109d568f49955652efe
Issue Description:
The followings are some inconsistencies between the grammar and the swift programs accepted by XCode or seen in the framework modules.
In grammar, "-" means the rules on in the grammar summary page. "+" shows modifications that work for me.
(1) Label allowed before do-statement in Xcode but not in grammar
Grammar:
Example:
(2) Optional "initializer-body" in "initializer-declaration"
Grammar:
Example:
(3) compiler-control statement can appear in declaration
Grammar:
Example:
(4) "nonmutating?" or "declaration-modifier" needed before "set" in "setter-keyword-clause"
Grammar:
Example:
(5) "nonmutating?" or "declaration-modifier" needed before "set" in "setter-clause"
Similar to (4)
(6) "attributes?" needed after "=" in "typealias-assignment"
Grammar:
Example:
(7) "type-annotation" has to be optional in some rules of "parameter"
Grammar:
Example:
(8) "attributes" needed in "parameter"
Grammar:
Example:
(9) "= default" in "default-argument-clause"
Grammar:
Example:
(10) "access-level-modifier" should be "declaration-modifiers" in "class-declaration"
Grammar:
Example:
(11) "attributes" in "extension-declaration"
Grammar:
Example:
(12) "where" can appear in extension declarations
Grammar:
Example:
(13) "subscript" may not have the code-body
Grammar:
Example:
(14) "assignment" in "infix-operator-attributes"
Grammar:
Example:
(15) The order of sub-rules in "infix-operator-attributes"
Grammar:
Example:
(16) "." in "enum-case-pattern" should be optional
Grammar:
Example:
(17) "statements" in "closure" can be optional
Grammar:
Example:
(18) "operator" should be allowed in "expression-element"
Grammar:
Example:
The text was updated successfully, but these errors were encountered: