mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
$vasplat was allowed inside of a function when passed as an argument to a function.
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
- `$defined` in a global scope should accept testing normal macros.
|
||||
- Assert on add to uninitialized ct variable #1765.
|
||||
- Dynamic function lookup fails after changing type without dummy anycast #1761
|
||||
- $vasplat was allowed inside of a function when passed as an argument to a function.
|
||||
|
||||
### Stdlib changes
|
||||
- Increase BitWriter.write_bits limit up to 32 bits.
|
||||
|
||||
@@ -1586,7 +1586,7 @@ INLINE bool sema_call_evaluate_arguments(SemaContext *context, CalledDecl *calle
|
||||
Expr *arg = args[i];
|
||||
if (i > 0) last = args[i - 1];
|
||||
ASSERT0(expr_ok(arg));
|
||||
if (arg->expr_kind == EXPR_VASPLAT)
|
||||
if (arg->expr_kind == EXPR_VASPLAT && context->current_macro)
|
||||
{
|
||||
Expr **new_args = sema_vasplat_insert(context, args, arg, i);
|
||||
if (!new_args) return false;
|
||||
|
||||
18
test/test_suite/macros/vasplat_function_call.c3
Normal file
18
test/test_suite/macros/vasplat_function_call.c3
Normal file
@@ -0,0 +1,18 @@
|
||||
import std;
|
||||
|
||||
def IList = List(<int>);
|
||||
fn IList IList.new(...) @operator(construct)
|
||||
{
|
||||
IList l;
|
||||
l.new_init($vasplat); // #error: can only be used inside
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
fn void main()
|
||||
{
|
||||
IList a = IList.new(123, 123, 123, 123, 123, 123, 123, 134);
|
||||
a.push(567);
|
||||
|
||||
io::printfn("%s", a[0]);
|
||||
}
|
||||
Reference in New Issue
Block a user