// Unified float→int narrowing rule (F0.11), NEGATIVE side: a NON-INTEGRAL float // implicitly narrowing to an integer-typed binding is a COMPILE ERROR — not a // silent truncation. The rule fires at a typed LOCAL initializer, a function // PARAM default, and a struct FIELD default; each emits a narrowing diagnostic // at the offending float and aborts (exit 1). It fires whether the float is a // LITERAL (`1.5`) or a compile-time const EXPRESSION (`M + 0.5`) — the latter is // the core of issue 0095, which previously slipped through and truncated to 2. // The fix is the integral-fold / non-integral-error rule shared with the // array-dimension path. // // The escape hatch stays open: `y : s64 = xx 1.5` (or `cast(s64) 1.5`) // truncates with no error — exercised on the POSITIVE side (example 0168). // // Regression (issue 0095): `y : s64 = 1.5` silently truncated to 1, and // `y : s64 = M + 0.5` silently truncated to 2. #import "modules/std.sx"; M :: 2; // module const, for the const-EXPRESSION cases Bad :: struct { f : s64 = 3.5; // non-integral float LITERAL field default → error fe : s64 = M + 0.5; // non-integral const-EXPRESSION field default → error } badLit :: (x : s64 = 2.5) -> s64 { return x; } // non-integral LITERAL param default → error badExpr :: (x : s64 = M + 0.5) -> s64 { return x; } // non-integral const-EXPR param default → error main :: () { y : s64 = 1.5; // non-integral float LITERAL local → error ye : s64 = M + 0.5; // non-integral const-EXPRESSION local → error b := Bad.{}; print("{} {}\n", b.f, b.fe); print("{} {}\n", badLit(), badExpr()); print("{} {}\n", y, ye); }