mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 21:10:30 +00:00
Remove dead #maybe code
This commit is contained in:
@@ -2595,7 +2595,6 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
||||
tok := expect_token(p, .Union)
|
||||
poly_params: ^ast.Field_List
|
||||
align: ^ast.Expr
|
||||
is_maybe: bool
|
||||
is_no_nil: bool
|
||||
is_shared_nil: bool
|
||||
|
||||
@@ -2620,10 +2619,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
||||
}
|
||||
align = parse_expr(p, true)
|
||||
case "maybe":
|
||||
if is_maybe {
|
||||
error(p, tag.pos, "duplicate union tag '#%s'", tag.text)
|
||||
}
|
||||
is_maybe = true
|
||||
error(p, tag.pos, "#%s functionality has now been merged with standard 'union' functionality", tag.text)
|
||||
case "no_nil":
|
||||
if is_no_nil {
|
||||
error(p, tag.pos, "duplicate union tag '#%s'", tag.text)
|
||||
@@ -2640,19 +2636,12 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
||||
}
|
||||
p.expr_level = prev_level
|
||||
|
||||
if is_no_nil && is_maybe {
|
||||
error(p, p.curr_tok.pos, "#maybe and #no_nil cannot be applied together")
|
||||
}
|
||||
if is_no_nil && is_shared_nil {
|
||||
error(p, p.curr_tok.pos, "#shared_nil and #no_nil cannot be applied together")
|
||||
}
|
||||
if is_shared_nil && is_maybe {
|
||||
error(p, p.curr_tok.pos, "#maybe and #shared_nil cannot be applied together")
|
||||
}
|
||||
|
||||
union_kind := ast.Union_Type_Kind.Normal
|
||||
switch {
|
||||
case is_maybe: union_kind = .maybe
|
||||
case is_no_nil: union_kind = .no_nil
|
||||
case is_shared_nil: union_kind = .shared_nil
|
||||
}
|
||||
|
||||
@@ -695,11 +695,6 @@ void check_union_type(CheckerContext *ctx, Type *union_type, Ast *node, Array<Op
|
||||
error(ut->align, "A union with #no_nil must have at least 2 variants");
|
||||
}
|
||||
break;
|
||||
case UnionType_maybe:
|
||||
if (variants.count != 1) {
|
||||
error(ut->align, "A union with #maybe must have at 1 variant, got %lld", cast(long long)variants.count);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (ut->align != nullptr) {
|
||||
|
||||
@@ -98,7 +98,6 @@ enum OdinDocTypeFlag_Struct : u32 {
|
||||
enum OdinDocTypeFlag_Union : u32 {
|
||||
OdinDocTypeFlag_Union_polymorphic = 1<<0,
|
||||
OdinDocTypeFlag_Union_no_nil = 1<<1,
|
||||
OdinDocTypeFlag_Union_maybe = 1<<2,
|
||||
OdinDocTypeFlag_Union_shared_nil = 1<<3,
|
||||
};
|
||||
|
||||
|
||||
@@ -2548,21 +2548,15 @@ Ast *parse_operand(AstFile *f, bool lhs) {
|
||||
syntax_error(tag, "Invalid union tag '#%.*s'", LIT(tag.string));
|
||||
}
|
||||
}
|
||||
if (no_nil && maybe) {
|
||||
syntax_error(f->curr_token, "#maybe and #no_nil cannot be applied together");
|
||||
}
|
||||
|
||||
if (no_nil && shared_nil) {
|
||||
syntax_error(f->curr_token, "#shared_nil and #no_nil cannot be applied together");
|
||||
}
|
||||
if (shared_nil && maybe) {
|
||||
syntax_error(f->curr_token, "#maybe and #shared_nil cannot be applied together");
|
||||
}
|
||||
|
||||
|
||||
if (maybe) {
|
||||
union_kind = UnionType_maybe;
|
||||
syntax_error(f->curr_token, "#maybe functionality has now been merged with standard 'union' functionality");
|
||||
} else if (no_nil) {
|
||||
}
|
||||
if (no_nil) {
|
||||
union_kind = UnionType_no_nil;
|
||||
} else if (shared_nil) {
|
||||
union_kind = UnionType_shared_nil;
|
||||
|
||||
@@ -339,7 +339,6 @@ char const *inline_asm_dialect_strings[InlineAsmDialect_COUNT] = {
|
||||
|
||||
enum UnionTypeKind : u8 {
|
||||
UnionType_Normal = 0,
|
||||
UnionType_maybe = 1, // removed
|
||||
UnionType_no_nil = 2,
|
||||
UnionType_shared_nil = 3,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user