add ability to explicitly cast float to integer

closes #414
This commit is contained in:
Andrew Kelley
2017-08-07 15:57:41 -04:00
parent 38b47d8aca
commit 2234788fa8
7 changed files with 58 additions and 12 deletions

View File

@@ -1945,4 +1945,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
\\}
,
".tmp_source.zig:2:15: error: float literal out of range of any type");
cases.add("explicit cast float literal to integer when there is a fraction component",
\\export fn entry() -> i32 {
\\ i32(12.34)
\\}
,
".tmp_source.zig:2:9: error: fractional component prevents float value 12.340000 from being casted to type 'i32'");
}