mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Deref subscripts as needed for macro ref method arguments. #1789
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
26
test/test_suite/macros/ref_macro_method.c3
Normal file
26
test/test_suite/macros/ref_macro_method.c3
Normal 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");
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user