diff --git a/doc/langref.html.in b/doc/langref.html.in index cfde67d622..4c6284ac43 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -248,7 +248,7 @@ pub fn main() !void {

Following the hello.zig Zig code sample, the {#link|Zig Build System#} is used - to build an executable program from the hello.zig source code. Then, the + to build an executable program from the hello.zig source code. Then, the hello program is executed showing its output Hello, world!. The lines beginning with $ represent command line prompts and a command. Everything else is program output. @@ -293,7 +293,7 @@ pub fn main() !void {

In Zig, a function's block of statements and expressions are surrounded by { and } curly-braces. Inside of the main function are expressions that perform - the task of outputting Hello, world! to standard output. + the task of outputting Hello, world! to standard output.

First, a constant identifier, stdout, is initialized to represent standard output's @@ -5135,6 +5135,22 @@ test "float widening" { var c: f64 = b; var d: f128 = c; assert(d == a); +} + {#code_end#} + {#header_close#} + {#header_open|Type Coercion: Coercion Float to Int#} +

+ A compiler error is appropriate because this ambiguous expression leaves the compiler + two choices about the coercion. +

+

+ {#code_begin|test_err#} +// Compile time coercion of float to int +test "implicit cast to comptime_int" { + var f: f32 = 54.0 / 5; } {#code_end#} {#header_close#} @@ -8179,7 +8195,7 @@ const expect = std.testing.expect; test "@src" { doTheTest(); } - + fn doTheTest() void { const src = @src();