refactor(types): shrink src/types.zig to editor/parse metadata (A8.2)
Remove the legacy parallel type model's compiler-like surface. The compiler pipeline resolves/lowers/lays out against canonical src/ir/types.zig (TypeId/TypeTable); src/types.zig.Type is now strictly editor-indexing + parse-time name metadata. - src/types.zig: delete the type-resolution surface (widen, bitWidth, isImplicitlyConvertibleTo) and every helper left dead once it was gone (eql, isInt/isFloat/isSigned/isUnsigned, isTuple/isVector, and the already-unused classification predicates isEnum/isUnion/isString/ isStringLike/isAny/optionalChild/sliceElementType/manyPointerElementType/ vectorElementType/isFunctionType/isClosureType/isCallable). Keep the Type union plus the display/name-classification helpers sema/lsp/parser use (fromName, fromTypeExpr, toName, displayName, isStruct/isOptional/isSlice/ isPointer/isManyPointer/isArray, pointerPointeeType). Seal the file with a doc comment. - src/sema.zig: inferExprType no longer calls Type.widen for arithmetic; it approximates the display type as the left operand's (no second resolver in the editor index). - src/ir/type_bridge.zig: delete the dead bridgeType (legacy Type -> TypeId) function + its sole sx_types import; resolveAstType and the AST->TypeId path are untouched. - src/ir/ir.zig: drop the bridgeType re-export. - src/ir/type_bridge.test.zig: drop the two bridgeType tests (function gone). Gate: zig build, zig build test (exit 0), tests/run_examples.sh 361/0, zero examples/expected churn.
This commit is contained in:
10
src/sema.zig
10
src/sema.zig
@@ -565,7 +565,7 @@ pub const Analyzer = struct {
|
||||
/// Infer an approximate editor `Type` for an expression (hover/completion;
|
||||
/// metadata only — NOT a compiler type decision, which uses `TypeId`).
|
||||
/// Uses fn_signatures for call return types, struct_types for field access,
|
||||
/// symbols for identifier types, and Type.widen for arithmetic promotion.
|
||||
/// and symbols for identifier types.
|
||||
pub fn inferExprType(self: *Analyzer, node: *const Node) Type {
|
||||
return switch (node.data) {
|
||||
.int_literal => Type.s(64),
|
||||
@@ -578,9 +578,13 @@ pub const Analyzer = struct {
|
||||
switch (binop.op) {
|
||||
.eq, .neq, .lt, .lte, .gt, .gte, .and_op, .or_op, .in_op => return .boolean,
|
||||
else => {
|
||||
// Editor display only: approximate an arithmetic result as
|
||||
// its left operand's type (or the right when the left is
|
||||
// unresolved). Numeric promotion is a compiler decision on
|
||||
// `TypeId`, never recomputed here.
|
||||
const lhs_ty = self.inferExprType(binop.lhs);
|
||||
const rhs_ty = self.inferExprType(binop.rhs);
|
||||
return Type.widen(lhs_ty, rhs_ty);
|
||||
if (lhs_ty == .unresolved) return self.inferExprType(binop.rhs);
|
||||
return lhs_ty;
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user