From 50139aa23245c7b6b6a5faff95f1a2c854051a38 Mon Sep 17 00:00:00 2001
From: Maks S <38307091+MadMax129@users.noreply.github.com>
Date: Sun, 28 Jun 2020 17:42:37 -0700
Subject: [PATCH] langref: explain why comptime_float cannot be divided by
comptime_int
Co-authored-by: Andrew Kelley
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. +