mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +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)
|
tok := expect_token(p, .Union)
|
||||||
poly_params: ^ast.Field_List
|
poly_params: ^ast.Field_List
|
||||||
align: ^ast.Expr
|
align: ^ast.Expr
|
||||||
is_maybe: bool
|
|
||||||
is_no_nil: bool
|
is_no_nil: bool
|
||||||
is_shared_nil: bool
|
is_shared_nil: bool
|
||||||
|
|
||||||
@@ -2620,10 +2619,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
|||||||
}
|
}
|
||||||
align = parse_expr(p, true)
|
align = parse_expr(p, true)
|
||||||
case "maybe":
|
case "maybe":
|
||||||
if is_maybe {
|
error(p, tag.pos, "#%s functionality has now been merged with standard 'union' functionality", tag.text)
|
||||||
error(p, tag.pos, "duplicate union tag '#%s'", tag.text)
|
|
||||||
}
|
|
||||||
is_maybe = true
|
|
||||||
case "no_nil":
|
case "no_nil":
|
||||||
if is_no_nil {
|
if is_no_nil {
|
||||||
error(p, tag.pos, "duplicate union tag '#%s'", tag.text)
|
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
|
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 {
|
if is_no_nil && is_shared_nil {
|
||||||
error(p, p.curr_tok.pos, "#shared_nil and #no_nil cannot be applied together")
|
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
|
union_kind := ast.Union_Type_Kind.Normal
|
||||||
switch {
|
switch {
|
||||||
case is_maybe: union_kind = .maybe
|
|
||||||
case is_no_nil: union_kind = .no_nil
|
case is_no_nil: union_kind = .no_nil
|
||||||
case is_shared_nil: union_kind = .shared_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");
|
error(ut->align, "A union with #no_nil must have at least 2 variants");
|
||||||
}
|
}
|
||||||
break;
|
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) {
|
if (ut->align != nullptr) {
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ enum OdinDocTypeFlag_Struct : u32 {
|
|||||||
enum OdinDocTypeFlag_Union : u32 {
|
enum OdinDocTypeFlag_Union : u32 {
|
||||||
OdinDocTypeFlag_Union_polymorphic = 1<<0,
|
OdinDocTypeFlag_Union_polymorphic = 1<<0,
|
||||||
OdinDocTypeFlag_Union_no_nil = 1<<1,
|
OdinDocTypeFlag_Union_no_nil = 1<<1,
|
||||||
OdinDocTypeFlag_Union_maybe = 1<<2,
|
|
||||||
OdinDocTypeFlag_Union_shared_nil = 1<<3,
|
OdinDocTypeFlag_Union_shared_nil = 1<<3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+3
-9
@@ -2548,21 +2548,15 @@ Ast *parse_operand(AstFile *f, bool lhs) {
|
|||||||
syntax_error(tag, "Invalid union tag '#%.*s'", LIT(tag.string));
|
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) {
|
if (no_nil && shared_nil) {
|
||||||
syntax_error(f->curr_token, "#shared_nil and #no_nil cannot be applied together");
|
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) {
|
if (maybe) {
|
||||||
union_kind = UnionType_maybe;
|
|
||||||
syntax_error(f->curr_token, "#maybe functionality has now been merged with standard 'union' functionality");
|
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;
|
union_kind = UnionType_no_nil;
|
||||||
} else if (shared_nil) {
|
} else if (shared_nil) {
|
||||||
union_kind = UnionType_shared_nil;
|
union_kind = UnionType_shared_nil;
|
||||||
|
|||||||
@@ -339,7 +339,6 @@ char const *inline_asm_dialect_strings[InlineAsmDialect_COUNT] = {
|
|||||||
|
|
||||||
enum UnionTypeKind : u8 {
|
enum UnionTypeKind : u8 {
|
||||||
UnionType_Normal = 0,
|
UnionType_Normal = 0,
|
||||||
UnionType_maybe = 1, // removed
|
|
||||||
UnionType_no_nil = 2,
|
UnionType_no_nil = 2,
|
||||||
UnionType_shared_nil = 3,
|
UnionType_shared_nil = 3,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user