Skip to content

Commit

Permalink
0.5.4: Hash variables accept designated initializers. @safemacro over…
Browse files Browse the repository at this point in the history
…rides the need for `@` in macro names. Fixes to macro context evaluation. Updated allocator api. Removed install_win_reqs.bat. Deterministic @init for MacOS. Fixed temp memory issue with formatter. Support LLVM 19. Add support to compare bitstructs using == and !=. Support Windows `.def` files. Removed invalid grammar from grammar.y. Support compile time folding of &|^~ for bitstructs. `output` project setting now respected. Fix issue where constants were not properly constant folded. Add temp_push/pop. Aliased declarations caused errors when used in initializers. Fix export output. Fix of const ternary #1118.
  • Loading branch information
lerno committed Feb 9, 2024
1 parent 0d2ba65 commit f6599c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Aliased declarations caused errors when used in initializers.
- Aliased consts used as constant initializers caused errors.
- Exported module names replace `::` by `_`.
- Const ternary would evaluate incorrectly for ?:

### Stdlib changes
- Deprecated `Allocator` helper functions.
Expand All @@ -32,6 +33,7 @@
- Mem "alloc_*" functions replace old "new_*" behaviour.
- Fixed temp memory issue with formatter.
- Added temp_push and temp_pop for pushing / popping the temp allocator manually (or from C).
- Added byte_size to `List`

## 0.5.3 Change list

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/sema_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ static inline bool sema_expr_analyse_ternary(SemaContext *context, Expr *expr)
{
Expr *copy = copy_expr_single(cond);
cast_no_check(context, copy, type_bool, false);
assert(expr_is_const(cond));
path = cond->const_expr.b ? 1 : 0;
assert(expr_is_const(copy));
path = copy->const_expr.b ? 1 : 0;
}
left = cond;
}
Expand Down
11 changes: 11 additions & 0 deletions test/unit/regression/ternary.c3
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module test @test;

fn void const_ternary()
{
int foo = 1;
const int FOO = 1;
assert((foo ?: 2) == 1);
assert((FOO ?: 2) == 1);
int bar = 2;
assert((FOO ?: bar) == 1);
}

0 comments on commit f6599c5

Please sign in to comment.