Bug due to missing cast when doing $i[$x] = $z.

Added `math::iota`.
This commit is contained in:
Christoffer Lerno
2025-03-16 10:58:13 +01:00
parent 5c77c9a754
commit 425676a98d
4 changed files with 16 additions and 2 deletions

View File

@@ -633,7 +633,7 @@ module std::core::mem;
macro TrackingEnv* get_tracking_env()
{
$if env::TRACK_MEMORY:
return &&TrackingEnv { $$FILE, $$FUNC, $$LINE };
return &&(TrackingEnv){ $$FILE, $$FUNC, $$LINE };
$else
return null;
$endif

View File

@@ -1145,6 +1145,18 @@ macro overflow_mul_helper(x, y) @local
return res;
}
<*
@require types::is_vector($Type) || ($Type.kindof == ARRAY &&& types::is_numerical($typefrom($Type.inner)))
*>
macro iota($Type)
{
$Type $val = {};
$for var $i = 0; $i < $Type.len; $i++:
$val[$i] = $i;
$endfor
return $val;
}
macro mul_div_helper(val, mul, div) @private
{
var $Type = $typeof(val);

View File

@@ -47,6 +47,7 @@
- `import` can now both be @public and @norecurse.
- Crash when trying to convert a struct slice to a vector #2039.
- Crash resolving a method on `Foo[2]` when `Foo` is distinct #2042.
- Bug due to missing cast when doing `$i[$x] = $z`.
### Stdlib changes
- `new_*` functions in general moved to version without `new_` prefix.
@@ -61,6 +62,7 @@
- Change all hash functions to have a common `hash` function.
- `@wstring`, `@wstring32`, `@char32` and `@char16` compile time macros added.
- Updates to `Atomic` to handle distinct types and booleans.
- Added `math::iota`.
## 0.6.8 Change list

View File

@@ -5745,7 +5745,7 @@ static bool sema_expr_analyse_ct_subscript_rhs(SemaContext *context, Decl *ct_va
}
else
{
if (!sema_analyse_inferred_expr(context, type_get_indexed_type(ct_var->type), right)) return false;
if (!sema_analyse_expr_rhs(context, type_get_indexed_type(ct_var->type), right, false, NULL, false)) return false;
}
if (!sema_cast_const(right))
{