ir: remaining lowering .s64 fallbacks -> .unresolved

Converts the leftover silent s64 guesses in lowering/type-resolution paths:
- target_type orelse .s64 in struct/tagged-union/enum-literal lowering and the
  xx-cast destination (the isBuiltin-guarded ones skip cleanly; the rest now
  surface instead of fabricating an int).
- resolveTypeArg / parameterized-type callee-name else arms.
- generic-mangle type-param binding miss (bindings.get orelse .s64).
- optional-child helper fallthrough.
Kept the genuine int/float-literal defaults (info.ty orelse .s64/.f64) which
are the language rule, not a lookup failure. 236 examples + unit green.
This commit is contained in:
agra
2026-05-30 00:29:03 +03:00
parent c6626b4f1a
commit d018541917

View File

@@ -3768,7 +3768,7 @@ pub const Lowering = struct {
if (sl.type_expr) |te| {
if (te.data == .enum_literal) {
const variant_name = te.data.enum_literal.name;
const union_ty = self.target_type orelse .s64;
const union_ty = self.target_type orelse .unresolved;
if (!union_ty.isBuiltin()) {
const union_info = self.module.types.get(union_ty);
if (union_info == .tagged_union) {
@@ -3784,7 +3784,7 @@ pub const Lowering = struct {
// user's values straight into the `(tag, payload_bytes)` slot
// pair and emit IR that LLVM later rejects.
if (sl.type_expr == null and sl.struct_name == null) {
const tu_ty = self.target_type orelse .s64;
const tu_ty = self.target_type orelse .unresolved;
if (!tu_ty.isBuiltin()) {
const tu_info = self.module.types.get(tu_ty);
if (tu_info == .tagged_union) {
@@ -3816,7 +3816,7 @@ pub const Lowering = struct {
} else if (sl.type_expr) |te|
// Generic struct literal: Pair(s32).{ ... } — resolve type from type_expr
self.resolveTypeWithBindings(te)
else self.target_type orelse .s64;
else self.target_type orelse .unresolved;
// Get struct field types for coercion and ordering
const struct_fields = self.getStructFields(ty);
@@ -4501,7 +4501,7 @@ pub const Lowering = struct {
}
fn lowerEnumLiteral(self: *Lowering, el: *const ast.EnumLiteral) Ref {
const target = self.target_type orelse .s64;
const target = self.target_type orelse .unresolved;
const tag = self.resolveVariantValue(target, el.name);
return self.builder.enumInit(tag, Ref.none, target);
}
@@ -5021,7 +5021,7 @@ pub const Lowering = struct {
const info = self.module.types.get(ty);
if (info == .optional) return info.optional.child;
}
return .s64;
return .unresolved;
}
// ── FFI intrinsics (#objc_call / #jni_call / #jni_static_call) ─
@@ -6205,7 +6205,7 @@ pub const Lowering = struct {
// from the union field type so struct literal fields get proper coercion
var enum_payload_ty: ?TypeId = null;
if (c.callee.data == .enum_literal) {
const target = self.target_type orelse .s64;
const target = self.target_type orelse .unresolved;
if (!target.isBuiltin()) {
const info = self.module.types.get(target);
if (info == .tagged_union) {
@@ -8485,7 +8485,7 @@ pub const Lowering = struct {
mangled_len += 1;
}
}
const ty = bindings.get(tp.name) orelse .s64;
const ty = bindings.get(tp.name) orelse .unresolved;
const type_name_str = self.mangleTypeName(ty);
for (type_name_str) |ch| {
if (mangled_len < mangled_buf.len) {
@@ -9879,7 +9879,7 @@ pub const Lowering = struct {
.function_type_expr,
.tuple_literal,
=> return type_bridge.resolveAstType(node, &self.module.types),
else => return .s64,
else => return .unresolved,
}
}
@@ -11133,7 +11133,7 @@ pub const Lowering = struct {
const callee_name: []const u8 = switch (cl.callee.data) {
.identifier => |id| id.name,
.field_access => |fa| fa.field,
else => return .s64,
else => return .unresolved,
};
// Built-in: Vector(N, T)
if (std.mem.eql(u8, callee_name, "Vector") and cl.args.len == 2) {
@@ -13259,7 +13259,7 @@ pub const Lowering = struct {
// and silently skip the user-space Into fallback.
const src_ty = self.builder.getRefType(operand);
const target_explicit = self.target_type != null;
const dst_ty = self.target_type orelse .s64;
const dst_ty = self.target_type orelse .unresolved;
// Any → concrete type: unbox
if (src_ty == .any) {