Deref subscripts as needed for macro ref method arguments. #1789

This commit is contained in:
Christoffer Lerno
2025-01-06 13:54:02 +01:00
parent 737559d3f8
commit 34c7f4e6b7
3 changed files with 28 additions and 0 deletions

View File

@@ -59,6 +59,7 @@
- Fix `+a = 1` erronously being accepted.
- Fix not freeing a zero length String
- Macros with trailing bodys aren't allowed as the single statement after a while loop with no body #1772.
- Deref subscripts as needed for macro ref method arguments. #1789
### Stdlib changes
- Increase BitWriter.write_bits limit up to 32 bits.

View File

@@ -1323,6 +1323,7 @@ static bool sema_analyse_parameter(SemaContext *context, Expr *arg, Decl *param,
switch (arg->expr_kind)
{
case EXPR_SUBSCRIPT:
if (type) break;
arg->expr_kind = EXPR_SUBSCRIPT_ADDR;
is_subscript = true;
break;

View File

@@ -0,0 +1,26 @@
import std::io;
struct MyStruct
{
DString* dyn;
}
fn void main()
{
@pool()
{
usz values_len = 10;
MyStruct ms = {
.dyn = mem::temp_new_array(DString, values_len).ptr,
};
for (usz i; i < values_len; ++i)
{
ms.dyn[i].temp_init();
}
ms.dyn[0].append_chars("sad");
ms.dyn[0].append("sad");
};
}