Remove mod_ty and panic

This change removes `.mod_ty` from parse type anno AST since it was not
user anywhere and `.ty` contains a `qualifiers` field, making `.mod_ty`
redundant.
This commit is contained in:
Jared Ramirez 2025-07-30 12:38:52 -07:00
parent 038af37b82
commit 0065acd1d6
No known key found for this signature in database
GPG key ID: 41158983F521D68C
5 changed files with 3 additions and 63 deletions

View file

@ -4407,9 +4407,6 @@ fn canonicalizeTypeAnnoHelp(self: *Self, anno_idx: AST.TypeAnno.Idx, type_anno_c
.ty => |ty| {
return (try self.canonicalizeTypeAnnoBasicType(ty)).anno_idx;
},
.mod_ty => |_| {
@panic("TODO mod_ty");
},
.underscore => |underscore| {
type_anno_ctx.found_underscore = true;
@ -5765,7 +5762,7 @@ fn extractTypeVarIdentsFromASTAnno(self: *Self, anno_idx: AST.TypeAnno.Idx, iden
try self.extractTypeVarIdentsFromASTAnno(field.ty, idents_start_idx);
}
},
.ty, .underscore, .mod_ty, .tag_union, .malformed => {
.ty, .underscore, .tag_union, .malformed => {
// These don't contain type variables to extract
},
}
@ -5841,7 +5838,7 @@ fn getTypeVarRegionFromAST(self: *Self, anno_idx: AST.TypeAnno.Idx, target_ident
}
return null;
},
.ty, .underscore, .mod_ty, .malformed => {
.ty, .underscore, .malformed => {
// These don't contain type variables
return null;
},

View file

@ -1845,11 +1845,6 @@ const Formatter = struct {
try fmt.pushTokenText(t.token);
},
.mod_ty => |t| {
try fmt.pushTokenText(t.region.start);
try fmt.pushAll(".");
try fmt.pushTokenText(t.region.end - 1);
},
.tuple => |t| {
region = t.region;
try fmt.formatCollection(t.region, .round, AST.TypeAnno.Idx, fmt.ast.store.typeAnnoSlice(t.annos), Formatter.formatTypeAnno);

View file

@ -1756,12 +1756,6 @@ pub const TypeAnno = union(enum) {
qualifiers: Token.Span,
region: TokenizedRegion,
},
mod_ty: struct {
mod_ident: base.Ident.Idx,
ty_ident: base.Ident.Idx,
// Region starts with the mod token and ends with the type token.
region: TokenizedRegion,
},
tag_union: struct {
tags: TypeAnno.Span,
open_anno: ?TypeAnno.Idx,
@ -1804,7 +1798,6 @@ pub const TypeAnno = union(enum) {
.underscore_type_var => |utv| return utv.region,
.underscore => |u| return u.region,
.ty => |t| return t.region,
.mod_ty => |t| return t.region,
.tag_union => |tu| return tu.region,
.tuple => |t| return t.region,
.record => |r| return r.region,
@ -1863,30 +1856,6 @@ pub const TypeAnno = union(enum) {
try tree.endNode(begin, attrs);
},
.mod_ty => |a| {
const begin = tree.beginNode();
try tree.pushStaticAtom("ty-mod");
const attrs = tree.beginNode();
const mod_text = env.idents.getText(a.mod_ident);
const type_text = env.idents.getText(a.ty_ident);
// module attribute
const module_begin = tree.beginNode();
try tree.pushStaticAtom("module");
try tree.pushString(mod_text);
const attrs2 = tree.beginNode();
try tree.endNode(module_begin, attrs2);
// name attribute
const name_begin = tree.beginNode();
try tree.pushStaticAtom("name");
try tree.pushString(type_text);
const attrs3 = tree.beginNode();
try tree.endNode(name_begin, attrs3);
try tree.endNode(begin, attrs);
},
.tag_union => |a| {
const begin = tree.beginNode();
try tree.pushStaticAtom("ty-tag-union");

View file

@ -43,7 +43,7 @@ pub const AST_STATEMENT_NODE_COUNT = 12;
/// Count of the pattern nodes in the AST
pub const AST_PATTERN_NODE_COUNT = 14;
/// Count of the type annotation nodes in the AST
pub const AST_TYPE_ANNO_NODE_COUNT = 11;
pub const AST_TYPE_ANNO_NODE_COUNT = 10;
/// Count of the expression nodes in the AST
pub const AST_EXPR_NODE_COUNT = 24;
@ -871,13 +871,6 @@ pub fn addTypeAnno(store: *NodeStore, anno: AST.TypeAnno) std.mem.Allocator.Erro
node.data.lhs = t.qualifiers.span.start;
node.data.rhs = t.qualifiers.span.len;
},
.mod_ty => |t| {
node.tag = .ty_mod_ty;
node.region = t.region;
node.main_token = t.region.start;
node.data.lhs = @bitCast(t.mod_ident);
node.data.rhs = @bitCast(t.ty_ident);
},
.tag_union => |tu| {
node.tag = .ty_union;
node.region = tu.region;
@ -1663,13 +1656,6 @@ pub fn getTypeAnno(store: *NodeStore, ty_anno_idx: AST.TypeAnno.Idx) AST.TypeAnn
.region = node.region,
} };
},
.ty_mod_ty => {
return .{ .mod_ty = .{
.mod_ident = @bitCast(node.data.lhs),
.ty_ident = @bitCast(node.data.rhs),
.region = node.region,
} };
},
.ty_union => {
const rhs = @as(AST.TypeAnno.TagUnionRhs, @bitCast(node.data.rhs));

View file

@ -404,13 +404,6 @@ test "NodeStore round trip - TypeAnno" {
.token = rand_token_idx(),
},
});
try ty_annos.append(AST.TypeAnno{
.mod_ty = .{
.mod_ident = rand_ident_idx(),
.ty_ident = rand_ident_idx(),
.region = rand_region(),
},
});
try ty_annos.append(AST.TypeAnno{
.tag_union = .{
.open_anno = rand_idx(AST.TypeAnno.Idx),