| ... | @@ -3839,7 +3839,7 @@ test "simple union" { | ... | @@ -3839,7 +3839,7 @@ test "simple union" { |
| 3839 | <p>Unions can be declared with an enum tag type. | 3839 | <p>Unions can be declared with an enum tag type. |
| 3840 | This turns the union into a <em>tagged</em> union, which makes it eligible | 3840 | This turns the union into a <em>tagged</em> union, which makes it eligible |
| 3841 | to use with {#link|switch#} expressions. | 3841 | to use with {#link|switch#} expressions. |
| 3842 | Tagged unions coerce to their tag type: {#link|Type Coercion: unions and enums#}. | 3842 | Tagged unions coerce to their tag type: {#link|Type Coercion: Unions and Enums#}. |
| 3843 | </p> | 3843 | </p> |
| 3844 | {#code_begin|test|test_tagged_union#} | 3844 | {#code_begin|test|test_tagged_union#} |
| 3845 | const std = @import("std"); | 3845 | const std = @import("std"); |
| ... | @@ -6275,7 +6275,7 @@ test "float widening" { | ... | @@ -6275,7 +6275,7 @@ test "float widening" { |
| 6275 | } | 6275 | } |
| 6276 | {#code_end#} | 6276 | {#code_end#} |
| 6277 | {#header_close#} | 6277 | {#header_close#} |
| 6278 | {#header_open|Type Coercion: Coercion Float to Int#} | 6278 | {#header_open|Type Coercion: Float to Int#} |
| 6279 | <p> | 6279 | <p> |
| 6280 | A compiler error is appropriate because this ambiguous expression leaves the compiler | 6280 | A compiler error is appropriate because this ambiguous expression leaves the compiler |
| 6281 | two choices about the coercion. | 6281 | two choices about the coercion. |
| ... | @@ -6427,7 +6427,7 @@ test "coercing large integer type to smaller one when value is comptime-known to | ... | @@ -6427,7 +6427,7 @@ test "coercing large integer type to smaller one when value is comptime-known to |
| 6427 | } | 6427 | } |
| 6428 | {#code_end#} | 6428 | {#code_end#} |
| 6429 | {#header_close#} | 6429 | {#header_close#} |
| 6430 | {#header_open|Type Coercion: unions and enums#} | 6430 | {#header_open|Type Coercion: Unions and Enums#} |
| 6431 | <p>Tagged unions can be coerced to enums, and enums can be coerced to tagged unions | 6431 | <p>Tagged unions can be coerced to enums, and enums can be coerced to tagged unions |
| 6432 | when they are {#link|comptime#}-known to be a field of the union that has only one possible value, such as | 6432 | when they are {#link|comptime#}-known to be a field of the union that has only one possible value, such as |
| 6433 | {#link|void#}: | 6433 | {#link|void#}: |
| ... | @@ -6487,7 +6487,7 @@ test "coercion between unions and enums" { | ... | @@ -6487,7 +6487,7 @@ test "coercion between unions and enums" { |
| 6487 | <p>{#link|undefined#} can be coerced to any type.</p> | 6487 | <p>{#link|undefined#} can be coerced to any type.</p> |
| 6488 | {#header_close#} | 6488 | {#header_close#} |
| 6489 | | 6489 | |
| 6490 | {#header_open|Type Coercion: tuples to arrays#} | 6490 | {#header_open|Type Coercion: Tuples to Arrays#} |
| 6491 | <p>{#link|Tuples#} can be coerced to arrays, if all of the fields have the same type.</p> | 6491 | <p>{#link|Tuples#} can be coerced to arrays, if all of the fields have the same type.</p> |
| 6492 | {#code_begin|test|test_coerce_tuples_arrays#} | 6492 | {#code_begin|test|test_coerce_tuples_arrays#} |
| 6493 | const std = @import("std"); | 6493 | const std = @import("std"); |