sema/ir: kill remaining s64 fallbacks (sema Type + getRefType)

- types.Type: add dedicated `unresolved` variant (mirrors ir.TypeId.unresolved)
  with eql/displayName arms; bridgeType maps it to TypeId.unresolved.
- sema.inferExprType + signature/field resolution: every Type.fromTypeExpr /
  fromName / symbol lookup miss and call/field/index fallthrough now yields
  Type.unresolved instead of a fabricated s(64). A variadic `..xs: []T` slice
  element is taken from T, not a guessed "s32". Genuine literal defaults
  (int=>s64, float=>f32, .len=>s64) kept.
- Builder.getRefType: an unlocatable ref (no active function / out-of-range)
  returns .unresolved, not .s64 -- this is the accurate type source the pack
  mono / binop / null-cmp fixes rely on, so it must not fabricate.

236 examples + unit tests (incl sema) green.
This commit is contained in:
agra
2026-05-30 00:38:23 +03:00
parent 8bc2ed4c49
commit f21b99c811
4 changed files with 33 additions and 19 deletions

View File

@@ -321,9 +321,11 @@ pub const Builder = struct {
blk.first_ref = self.inst_counter;
}
/// Get the type of a previously emitted instruction Ref.
/// Get the type of a previously emitted instruction Ref. A ref that can't
/// be located (no active function, or an out-of-range ref) has no knowable
/// type — return the `.unresolved` sentinel rather than a fabricated `.s64`.
pub fn getRefType(self: *Builder, ref: Ref) TypeId {
if (self.func == null) return .s64;
if (self.func == null) return .unresolved;
const func = self.currentFunc();
const ref_idx = @intFromEnum(ref);
// Check function parameters first (refs 0..N-1)
@@ -336,7 +338,7 @@ pub const Builder = struct {
return block.insts.items[ref_idx - first].ty;
}
}
return .s64;
return .unresolved;
}
// ── Emit helpers ────────────────────────────────────────────────