diff options
| author | Kevin Watters <kevinwatters@gmail.com> | 2019-04-01 09:34:25 -0400 |
|---|---|---|
| committer | Kevin Watters <kevinwatters@gmail.com> | 2019-04-01 09:34:25 -0400 |
| commit | 957e1e1f07db06ff241bc43be737e1b9becf5fdd (patch) | |
| tree | ceb701b0d18bfa0ea6b352d8182e4652df2ed9d0 /src/check_type.cpp | |
| parent | 381fbd3dafed820583c97f176d2694b21358d178 (diff) | |
| parent | 133f88406f77db28ec041399b00770046469934d (diff) | |
Merge branch 'master' of github.com:odin-lang/Odin
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index 22cd409ee..445b93fb8 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -759,6 +759,8 @@ void check_enum_type(CheckerContext *ctx, Type *enum_type, Type *named_type, Ast ExactValue iota = exact_value_i64(-1); ExactValue min_value = exact_value_i64(0); ExactValue max_value = exact_value_i64(0); + bool min_value_set = false; + bool max_value_set = false; scope_reserve(ctx->scope, et->fields.count); @@ -810,11 +812,21 @@ void check_enum_type(CheckerContext *ctx, Type *enum_type, Type *named_type, Ast continue; } - if (compare_exact_values(Token_Gt, min_value, iota)) { + if (min_value_set) { + if (compare_exact_values(Token_Gt, min_value, iota)) { + min_value = iota; + } + } else { min_value = iota; + min_value_set = true; } - if (compare_exact_values(Token_Lt, max_value, iota)) { + if (max_value_set) { + if (compare_exact_values(Token_Lt, max_value, iota)) { + max_value = iota; + } + } else { max_value = iota; + max_value_set = true; } Entity *e = alloc_entity_constant(ctx->scope, ident->Ident.token, constant_type, iota); |