mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 03:50:16 +00:00
...
This commit is contained in:
parent
754808412b
commit
fe00542124
@ -687,13 +687,14 @@ struct CallExpr: Expr{
|
||||
ctx->emit(OP_BUILD_TUPLE_UNPACK, (int)args.size(), line);
|
||||
|
||||
for(auto& item: kwargs){
|
||||
item.second->emit(ctx);
|
||||
if(item.second->is_starred()){
|
||||
if(item.second->star_level() != 2) FATAL_ERROR();
|
||||
item.second->emit(ctx);
|
||||
}else{
|
||||
// k=v
|
||||
int index = ctx->add_const(py_var(ctx->vm, item.first));
|
||||
ctx->emit(OP_LOAD_CONST, index, line);
|
||||
item.second->emit(ctx);
|
||||
ctx->emit(OP_BUILD_TUPLE, 2, line);
|
||||
}
|
||||
}
|
||||
|
@ -52,4 +52,15 @@ try:
|
||||
x = f1(*[1, 2, 3, 4])
|
||||
exit(1)
|
||||
except TypeError:
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
def g(*args, **kwargs):
|
||||
return args, kwargs
|
||||
|
||||
def f(a, b, *args, c=1, **kwargs):
|
||||
return g(a, b, *args, c=c, **kwargs)
|
||||
|
||||
args, kwargs = f(1, 2, 3, 4, c=5, d=6, e=-6.0)
|
||||
assert args == (1, 2, 3, 4)
|
||||
assert kwargs == {'c': 5, 'd': 6, 'e': -6.0}
|
Loading…
x
Reference in New Issue
Block a user