aboutsummaryrefslogtreecommitdiff
path: root/src/compile/promotions.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-21 12:04:38 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-21 12:04:38 -0400
commite419a527a1212123946e53adaaea01df0c5605c3 (patch)
tree950d3f06b13be2e25fdd33cbda69d8a30f34fff9 /src/compile/promotions.c
parentb9a8ddea2c0b5f170e461b9216eb14f2d86588eb (diff)
Add enum scope when declaring a variable
Diffstat (limited to 'src/compile/promotions.c')
-rw-r--r--src/compile/promotions.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/compile/promotions.c b/src/compile/promotions.c
index 6595e5aa..26f3af9f 100644
--- a/src/compile/promotions.c
+++ b/src/compile/promotions.c
@@ -114,6 +114,11 @@ bool promote(env_t *env, ast_t *ast, Text_t *code, type_t *actual, type_t *neede
public
Text_t compile_to_type(env_t *env, ast_t *ast, type_t *t) {
assert(!is_incomplete_type(t));
+
+ if (t->tag == EnumType) {
+ env = with_enum_scope(env, t);
+ }
+
if (ast->tag == Int && is_numeric_type(non_optional(t))) {
return compile_int_to_type(env, ast, t);
} else if (ast->tag == Num && t->tag == NumType) {