mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix bug where .min/.max would fail on a distinct int #1888.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
- Filter `$exec` output from `\r`, which otherwise would cause a compiler assert #1867.
|
||||
- Fixes to `"exec" use, including issue when compiling with MinGW.
|
||||
- Correctly check jump table size and be generous when compiling it #1877.
|
||||
- Fix bug where .min/.max would fail on a distinct int #1888.
|
||||
|
||||
### Stdlib changes
|
||||
- Added '%h' and '%H' for printing out binary data in hexadecimal using the formatter.
|
||||
|
||||
@@ -472,6 +472,7 @@ CondResult sema_check_comp_time_bool(SemaContext *context, Expr *expr)
|
||||
|
||||
static bool sema_binary_is_expr_lvalue(SemaContext *context, Expr *top_expr, Expr *expr, bool *failed_ref)
|
||||
{
|
||||
if (expr->expr_kind == EXPR_CT_SUBSCRIPT) return true;
|
||||
switch (expr->expr_kind)
|
||||
{
|
||||
case UNRESOLVED_EXPRS:
|
||||
@@ -4325,7 +4326,7 @@ static inline bool sema_create_const_min(SemaContext *context, Expr *expr, Type
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (type_is_integer(type))
|
||||
else if (type_is_integer(flat))
|
||||
{
|
||||
expr->expr_kind = EXPR_CONST;
|
||||
expr->const_expr.const_kind = CONST_INTEGER;
|
||||
@@ -7557,7 +7558,9 @@ static inline bool sema_expr_analyse_not(SemaContext *context, Expr *expr)
|
||||
|
||||
static inline bool sema_expr_analyse_ct_incdec(SemaContext *context, Expr *expr, Expr *inner)
|
||||
{
|
||||
ASSERT_SPAN(expr, inner->expr_kind == EXPR_CT_IDENT);
|
||||
ASSERT_SPAN(expr, inner->expr_kind == EXPR_CT_IDENT || inner->expr_kind == EXPR_CT_SUBSCRIPT);
|
||||
|
||||
if (inner->expr_kind == EXPR_CT_SUBSCRIPT) TODO
|
||||
|
||||
Decl *var = inner->ct_ident_expr.decl;
|
||||
Expr *start_value = var->var.init_expr;
|
||||
@@ -7681,7 +7684,7 @@ static inline bool sema_expr_analyse_incdec(SemaContext *context, Expr *expr)
|
||||
if (!sema_expr_check_assign(context, inner, NULL)) return false;
|
||||
|
||||
// 3. This might be a $foo, if to handle it.
|
||||
if (inner->expr_kind == EXPR_CT_IDENT)
|
||||
if (inner->expr_kind == EXPR_CT_IDENT || inner->expr_kind == EXPR_CT_SUBSCRIPT)
|
||||
{
|
||||
return sema_expr_analyse_ct_incdec(context, expr, inner);
|
||||
}
|
||||
|
||||
8
test/test_suite/distinct/distinct_max.c3t
Normal file
8
test/test_suite/distinct/distinct_max.c3t
Normal file
@@ -0,0 +1,8 @@
|
||||
module test;
|
||||
distinct Time = long;
|
||||
|
||||
fn void main(String[] args)
|
||||
{
|
||||
Time.min;
|
||||
Time.max;
|
||||
}
|
||||
Reference in New Issue
Block a user