aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-03-06 16:23:50 +0000
committergingerBill <bill@gingerbill.org>2019-03-06 16:23:50 +0000
commit15d3f4c190abbeaef2cd6920d16aacaf71c35fe1 (patch)
treed9155251f3a95a9da92b4d23c6412000160e7a2c
parent1b3ec66fa2cf6f9a8f15d9c1988db677ac1a6fa6 (diff)
Allow implicit selector expressions in switch statements
-rw-r--r--core/fmt/fmt.odin14
-rw-r--r--src/check_stmt.cpp6
2 files changed, 9 insertions, 11 deletions
diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin
index 0df06c0ec..344f61e80 100644
--- a/core/fmt/fmt.odin
+++ b/core/fmt/fmt.odin
@@ -468,11 +468,10 @@ _fmt_int :: proc(fi: ^Info, u: u64, base: int, is_signed: bool, bit_size: int, d
buf: [256]byte;
start := 0;
- using strconv.Int_Flag;
flags: strconv.Int_Flags;
- if fi.hash && !fi.zero do flags |= {Prefix};
- if fi.plus do flags |= {Plus};
- if fi.space do flags |= {Space};
+ if fi.hash && !fi.zero do flags |= {.Prefix};
+ if fi.plus do flags |= {.Plus};
+ if fi.space do flags |= {.Space};
s := strconv.append_bits(buf[start:], u, base, is_signed, bit_size, digits, flags);
if fi.hash && fi.zero {
@@ -746,11 +745,10 @@ fmt_bit_set :: proc(fi: ^Info, v: any, name: string = "") {
ti = runtime.type_info_base(ti);
switch info in ti.variant {
case runtime.Type_Info_Integer:
- using runtime.Type_Info_Endianness;
switch info.endianness {
- case Platform: return false;
- case Little: return ODIN_ENDIAN != "little";
- case Big: return ODIN_ENDIAN != "big";
+ case .Platform: return false;
+ case .Little: return ODIN_ENDIAN != "little";
+ case .Big: return ODIN_ENDIAN != "big";
}
}
return false;
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp
index c861cfdf3..cead61ce8 100644
--- a/src/check_stmt.cpp
+++ b/src/check_stmt.cpp
@@ -686,14 +686,14 @@ void check_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) {
ast_node(ie, BinaryExpr, expr);
Operand lhs = {};
Operand rhs = {};
- check_expr(ctx, &lhs, ie->left);
+ check_expr_with_type_hint(ctx, &lhs, ie->left, x.type);
if (x.mode == Addressing_Invalid) {
continue;
}
if (lhs.mode == Addressing_Invalid) {
continue;
}
- check_expr(ctx, &rhs, ie->right);
+ check_expr_with_type_hint(ctx, &rhs, ie->right, x.type);
if (rhs.mode == Addressing_Invalid) {
continue;
}
@@ -732,7 +732,7 @@ void check_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) {
if (is_type_typeid(x.type)) {
check_expr_or_type(ctx, &y, expr, x.type);
} else {
- check_expr(ctx, &y, expr);
+ check_expr_with_type_hint(ctx, &y, expr, x.type);
}
if (x.mode == Addressing_Invalid ||