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
Copy file name to clipboardExpand all lines: docs/Diagnostics.md
+19-2
Original file line number
Diff line number
Diff line change
@@ -38,8 +38,23 @@ Clang also has a kind of diagnostic called a "remark", which represents informat
38
38
39
39
- When applicable, phrase diagnostics as rules rather than reporting that the compiler failed to do something. Example:
40
40
41
-
- Normal: "cannot call 'super.init' outside of an initializer"
42
-
- Better: "'super.init' cannot be called outside of an initializer"
41
+
- Normal: `cannot call 'super.init' outside of an initializer`
42
+
- Better: `'super.init' cannot be called outside of an initializer`
43
+
44
+
- Use `'` to quote attributes, symbol names, and any other text that is
45
+
referred to as code or a token.
46
+
Some idiomatic Swift tokens, such as `protocol`, by themselves are or appear
47
+
in Swift terms of art.
48
+
Terms of art are written in plain text and must not be quoted.
49
+
If you are not certain whether a Swift token has an associated term of art,
50
+
consult the [book].
51
+
For example:
52
+
-`'mutating' is only valid on methods`, but
53
+
`cannot call mutating method on immutable value`.
54
+
-`'@autoclosure' only applies to function types`.
55
+
-`subscript access can throw but is not marked with 'try'`.
56
+
-`expected '{' after 'defer'`.
57
+
-`type 'S' does not conform to protocol 'Sequence'`.
43
58
44
59
- When referring to attributes by name, use *either*`attribute 'foo'` or
45
60
`'@foo'`, rather than `attribute '@foo'`.
@@ -54,6 +69,8 @@ Clang also has a kind of diagnostic called a "remark", which represents informat
54
69
55
70
- If possible, it is best to include the name of the type or function that has the error, e.g. "non-actor type 'Nope' cannot ..." is better than "non-actor type cannot ...". It helps developers relate the error message to the specific type the error is about, even if the error would highlight the appropriate line / function in other ways.
0 commit comments