lang: rename signed integer types sN -> iN
Surface rename of the signed integer family: s1..s64 become i1..i64
(u1..u64, usize, isize unchanged). 'string' keeps the s-prefix arm in
name classification; width parsing moves to the i-prefix arm next to
isize.
Internal TypeId tags follow the surface (.s8/.s16/.s32/.s64 ->
.i8/.i16/.i32/.i64), as do mono-key mangle fragments (ptr_i64,
tu_i64_bool) and all display/diagnostic formatting (i{d}).
Migrated in the same sweep: stdlib + examples + issue repros + FFI C
companions (shared symbol names like ffi_id_i64), expected
stdout/stderr/ir snapshots, specs.md, readme.md, CLAUDE.md/AGENTS.md,
implementation_plan.md, docs/, issue writeups. Vendored stb_image and
historical flow state left untouched.
zig build test: 426/426; examples suite: 595/595.
This commit is contained in:
@@ -18,14 +18,14 @@ Coverage via the shared arm: decls, assignments, call args, struct-literal
|
||||
fields, struct constants, globals.
|
||||
|
||||
**Behavior change:** `examples/0300-closures-lambda.sx` passed `133` to an
|
||||
`s3` param and pinned the wrapped `-3`; updated to a fitting value.
|
||||
`i3` param and pinned the wrapped `-3`; updated to a fitting value.
|
||||
|
||||
**Regression tests:** `examples/1156-diagnostics-int-literal-out-of-range.sx`
|
||||
(both faces diagnosed in one run) and
|
||||
`examples/0174-types-int-literal-boundaries.sx` (extreme in-range values,
|
||||
width-64 types, `xx`/`cast` escapes, call args).
|
||||
|
||||
**Found during the fix:** negated-literal GLOBAL initializers (`g : s64 = -1;`)
|
||||
**Found during the fix:** negated-literal GLOBAL initializers (`g : i64 = -1;`)
|
||||
are rejected as non-constant — pre-existing gap, filed as issue 0113.
|
||||
|
||||
---
|
||||
@@ -33,10 +33,10 @@ are rejected as non-constant — pre-existing gap, filed as issue 0113.
|
||||
# 0112 — out-of-range int literal silently wraps into a narrower annotated target
|
||||
|
||||
**Symptom.** An integer literal that does not fit its explicitly-annotated
|
||||
integer target truncates with no diagnostic: `x : s8 = 300;` binds 44,
|
||||
integer target truncates with no diagnostic: `x : i8 = 300;` binds 44,
|
||||
`y : u8 = 256;` binds 0. Expected: a compile-time error (the value is known
|
||||
exactly at compile time; this is the integer analogue of the float→int
|
||||
narrowing rule, which errors on non-exact `y : s64 = 1.5`).
|
||||
narrowing rule, which errors on non-exact `y : i64 = 1.5`).
|
||||
|
||||
Split from issue 0111 (whose fix removed the *implicit* narrowing — an
|
||||
unannotated `x := 0` no longer adopts the fn return type — but the explicit
|
||||
@@ -48,7 +48,7 @@ annotation path keeps wrapping).
|
||||
#import "modules/std.sx";
|
||||
|
||||
main :: () {
|
||||
x : s8 = 300;
|
||||
x : i8 = 300;
|
||||
print("x: {}\n", x);
|
||||
y : u8 = 256;
|
||||
print("y: {}\n", y);
|
||||
@@ -58,7 +58,7 @@ main :: () {
|
||||
- **Observed** (current master): prints `x: 44` / `y: 0`, exit 0, no
|
||||
diagnostic.
|
||||
- **Expected**: compile error per literal, e.g.
|
||||
`integer literal 300 does not fit in s8 (range -128..127)`, and the analog
|
||||
`integer literal 300 does not fit in i8 (range -128..127)`, and the analog
|
||||
for `256` / `u8 (range 0..255)`.
|
||||
|
||||
Repro co-located: `issues/0112-int-literal-out-of-range-silent-wrap.sx`
|
||||
@@ -72,7 +72,7 @@ value truncates at LLVM emission width. The annotated-decl path
|
||||
(`lowerVarDecl` with `type_annotation`, `src/ir/lower/stmt.zig` ~255) sets
|
||||
`target_type` to the annotation before lowering the initializer, so every
|
||||
annotated narrow decl funnels through this arm. Assignments to narrow
|
||||
lvalues (`b = 300` where `b: s8`) reach the same arm via `lowerAssignment`'s
|
||||
lvalues (`b = 300` where `b: i8`) reach the same arm via `lowerAssignment`'s
|
||||
LHS-derived target and likely need the same check.
|
||||
|
||||
## Investigation prompt (paste into a fresh session)
|
||||
@@ -84,15 +84,15 @@ LHS-derived target and likely need the same check.
|
||||
> table knows both; mirror the bounds logic used by
|
||||
> `TypeResolver.integerLimitFor`). On overflow emit a diagnostic via
|
||||
> `self.diagnostics.addFmt(.err, node.span, ...)` naming the literal, the
|
||||
> type, and its range — do NOT silently fall back to s64 (REJECTED PATTERNS:
|
||||
> type, and its range — do NOT silently fall back to i64 (REJECTED PATTERNS:
|
||||
> no silent fallback defaults); still return a `constInt` of the target type
|
||||
> so lowering continues to surface further errors. Audit sibling literal
|
||||
> sinks that bypass this arm (comptime folds, `lowerStructConstant`, global
|
||||
> initializers) for the same check.
|
||||
>
|
||||
> Verify: `issues/0112-int-literal-out-of-range-silent-wrap.sx` errors with
|
||||
> two diagnostics (s8/300, u8/256); boundary values still compile
|
||||
> (`x : s8 = -128` / `127`, `y : u8 = 0` / `255`, `m : u64` large literals).
|
||||
> two diagnostics (i8/300, u8/256); boundary values still compile
|
||||
> (`x : i8 = -128` / `127`, `y : u8 = 0` / `255`, `m : u64` large literals).
|
||||
> `zig build && zig build test && bash tests/run_examples.sh` — any example
|
||||
> that relied on silent wrapping must be reviewed individually. Promote the
|
||||
> repro per the resolution flow (likely `examples/11xx-diagnostics-...`).
|
||||
|
||||
Reference in New Issue
Block a user