diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-11-24 22:14:15 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-11-24 22:14:15 -0500 |
| commit | af585cf127a26148372fe54eb62d1c9fad6f2dba (patch) | |
| tree | dd7225692c87a243f4ef3ffc7245f36ecbc6803f /src | |
| parent | bbf7a60dcd524c2d86ac7efe7bc97d4a627b6d15 (diff) | |
Fix for `when` blocks with a single expression inside
Diffstat (limited to 'src')
| -rw-r--r-- | src/compile/promotions.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/compile/promotions.c b/src/compile/promotions.c index b3cbb361..93ad5338 100644 --- a/src/compile/promotions.c +++ b/src/compile/promotions.c @@ -127,6 +127,10 @@ Text_t compile_to_type(env_t *env, ast_t *ast, type_t *t) { env = with_enum_scope(env, t); } + if (ast->tag == Block && Match(ast, Block)->statements && !Match(ast, Block)->statements->next) { + ast = Match(ast, Block)->statements->ast; + } + 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) { |
