Skip to content

Commit 91fd19d

Browse files
committed
[Docs] Correct a few code blocks in TypeChecker.md
1 parent 6173d7e commit 91fd19d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

docs/TypeChecker.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,12 @@ issue noted in the prior section is that this constraint does not give
367367
the solver enough information to determine ``T0`` without
368368
guesswork. However, we note that the type of an enum member actually
369369
has a regular structure. For example, consider the ``Optional`` type::
370-
370+
```swift
371371
enum Optional<T> {
372372
case none
373373
case some(T)
374374
}
375-
375+
```
376376
The type of ``Optional<T>.none`` is ``Optional<T>``, while the type of
377377
``Optional<T>.some`` is ``(T) -> Optional<T>``. In fact, the
378378
type of an enum element can have one of two forms: it can be ``T0``,
@@ -388,12 +388,12 @@ The Swift language includes generics, a system of constrained
388388
parameter polymorphism that enables polymorphic types and
389389
functions. For example, one can implement a ``min`` function as,
390390
e.g.,::
391-
391+
```swift
392392
func min<T : Comparable>(x: T, y: T) -> T {
393393
if y < x { return y }
394394
return x
395395
}
396-
396+
```
397397
Here, ``T`` is a generic parameter that can be replaced with any
398398
concrete type, so long as that type conforms to the protocol
399399
``Comparable``. The type of ``min`` is (internally) written as ``<T :
@@ -424,11 +424,11 @@ cannot declare a variable of type ``<T> T -> T``.
424424

425425
Uses of generic types are also immediately opened by the constraint
426426
solver. For example, consider the following generic dictionary type::
427-
427+
```swift
428428
class Dictionary<Key : Hashable, Value> {
429429
// ...
430430
}
431-
431+
```
432432
When the constraint solver encounters the expression ``Dictionary()``,
433433
it opens up the type ``Dictionary``---which has not
434434
been provided with any specific generic arguments---to the type
@@ -496,9 +496,9 @@ relationship constraints proceeds by comparing the structure of the
496496
two types and applying the typing rules of the Swift language to
497497
generate additional constraints. For example, if the constraint is a
498498
conversion constraint::
499-
499+
```
500500
A -> B <c C -> D
501-
501+
```
502502
then both types are function types, and we can break down this
503503
constraint into two smaller constraints ``C < A`` and ``B < D`` by
504504
applying the conversion rule for function types. Similarly, one can
@@ -715,7 +715,7 @@ well as during diagnostics emission, it is important to track the
715715
relationship between the constraints and the actual AST nodes from
716716
which they originally came. For example, consider the following type
717717
checking problem::
718-
```
718+
```swift
719719
struct X {
720720
// user-defined conversions
721721
func [conversion] __conversion () -> String { /* ... */ }
@@ -827,7 +827,7 @@ Simplification does not always exhaust the complete path. For example,
827827
consider a slight modification to our example, so that the argument to
828828
``f`` is provided by another call, we get a different result
829829
entirely::
830-
```
830+
```swift
831831
func f(_ i : Int, s : String) { }
832832
func g() -> (f : Float, x : X) { }
833833

@@ -844,9 +844,9 @@ argument" derivation step takes us to the argument expression
844844
element of ``g()``, because it's simple part of the tuple returned
845845
from ``g``. At this point, simplification ceases, and creates the
846846
simplified locator::
847-
847+
```
848848
function application of g -> tuple element #0
849-
849+
```
850850
### Performance
851851

852852
The performance of the type checker is dependent on a number of

0 commit comments

Comments
 (0)