mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
fix read_literal
This commit is contained in:
parent
b021dc0b2a
commit
3688f69123
@ -6,7 +6,7 @@
|
|||||||
typedef struct{
|
typedef struct{
|
||||||
SourceData_ src;
|
SourceData_ src;
|
||||||
int lineno;
|
int lineno;
|
||||||
char msg[100];
|
char msg[512];
|
||||||
} Error;
|
} Error;
|
||||||
|
|
||||||
void py_BaseException__stpush(py_Ref, SourceData_ src, int lineno, const char* func_name);
|
void py_BaseException__stpush(py_Ref, SourceData_ src, int lineno, const char* func_name);
|
||||||
|
@ -2346,7 +2346,9 @@ static Error* read_literal(Compiler* self, py_Ref out) {
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
default: py_newnil(out); return NULL;
|
default: {
|
||||||
|
return SyntaxError(self, "expected a literal, got '%s'", TokenSymbols[prev()->type]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2385,7 +2387,6 @@ static Error* _compile_f_args(Compiler* self, FuncDecl* decl, bool is_lambda) {
|
|||||||
consume(TK_ASSIGN);
|
consume(TK_ASSIGN);
|
||||||
py_TValue value;
|
py_TValue value;
|
||||||
check(read_literal(self, &value));
|
check(read_literal(self, &value));
|
||||||
if(py_isnil(&value)) return SyntaxError(self, "default argument must be a literal");
|
|
||||||
FuncDecl__add_kwarg(decl, name, &value);
|
FuncDecl__add_kwarg(decl, name, &value);
|
||||||
} break;
|
} break;
|
||||||
case 3:
|
case 3:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user