From 416051f17b7e8375b2bc4823727c0f67d7ad9beb Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 14 Dec 2020 16:39:31 +0000 Subject: Fix #811 --- src/check_expr.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/check_expr.cpp') diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 15380e55c..b0012bfcc 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -8760,8 +8760,10 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type i64 lo = exact_value_to_i64(x.value); i64 hi = exact_value_to_i64(y.value); i64 max_index = hi; - if (op.kind == Token_RangeHalf) { + if (op.kind == Token_RangeHalf) { // ..< (exclusive) hi -= 1; + } else { // .. (inclusive) + max_index += 1; } bool new_range = range_cache_add_range(&rc, lo, hi); -- cgit v1.2.3 From 720f2c7c61ddfc79deba2bb29b3727b50314cafb Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 17 Dec 2020 14:23:45 +0000 Subject: Allow `check_expr_with_type_hint` to allow assignment of types to typeid without requiring `typeid_of` --- src/check_expr.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/check_expr.cpp') diff --git a/src/check_expr.cpp b/src/check_expr.cpp index b0012bfcc..63b275c99 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -7910,7 +7910,9 @@ void check_expr_with_type_hint(CheckerContext *c, Operand *o, Ast *e, Type *t) { err_str = "used as a value"; break; case Addressing_Type: - err_str = "is not an expression but a type"; + if (t == nullptr || !is_type_typeid(t)) { + err_str = "is not an expression but a type"; + } break; case Addressing_Builtin: err_str = "must be called"; -- cgit v1.2.3