mirror of
https://github.com/pocketpy/pocketpy
synced 2026-02-06 07:30:17 +00:00
fix #458
This commit is contained in:
parent
82b4fff934
commit
cbbe319520
@ -2301,6 +2301,9 @@ static Error* _compile_f_args(Compiler* self, FuncDecl* decl, bool is_lambda) {
|
|||||||
int state = 0; // 0 for args, 1 for *args, 2 for k=v, 3 for **kwargs
|
int state = 0; // 0 for args, 1 for *args, 2 for k=v, 3 for **kwargs
|
||||||
Error* err;
|
Error* err;
|
||||||
do {
|
do {
|
||||||
|
// allow trailing comma
|
||||||
|
if(!is_lambda && curr()->type == TK_RPAREN) break;
|
||||||
|
|
||||||
if(state >= 3) return SyntaxError(self, "**kwargs should be the last argument");
|
if(state >= 3) return SyntaxError(self, "**kwargs should be the last argument");
|
||||||
if(match(TK_MUL)) {
|
if(match(TK_MUL)) {
|
||||||
if(state < 1)
|
if(state < 1)
|
||||||
|
|||||||
@ -156,6 +156,17 @@ def f(a,
|
|||||||
|
|
||||||
assert f(1, 2) == 3
|
assert f(1, 2) == 3
|
||||||
|
|
||||||
|
|
||||||
|
# https://github.com/pocketpy/pocketpy/issues/458
|
||||||
|
def f(
|
||||||
|
x: int,
|
||||||
|
y: int,
|
||||||
|
):
|
||||||
|
return x + y
|
||||||
|
|
||||||
|
assert f(1, 2) == 3
|
||||||
|
|
||||||
|
|
||||||
# try:
|
# try:
|
||||||
# f(a=1)
|
# f(a=1)
|
||||||
# exit(1)
|
# exit(1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user