Compare commits

...

3 Commits

Author SHA1 Message Date
blueloveTH
24428793fc fix #434 2026-02-05 11:33:22 +08:00
blueloveTH
d5b711f50c fix #447 2026-02-05 11:27:12 +08:00
blueloveTH
cbbe319520 fix #458 2026-02-05 11:20:11 +08:00
6 changed files with 61 additions and 13 deletions

View File

@ -60,16 +60,18 @@ def filter(f, iterable):
if f(i): if f(i):
yield i yield i
def zip(a, b): class zip:
a = iter(a) def __init__(self, *iterables):
b = iter(b) self.iterables = [iter(it) for it in iterables]
while True:
try: def __iter__(self):
ai = next(a) return self
bi = next(b)
except StopIteration: def __next__(self):
break result = []
yield ai, bi for it in self.iterables:
result.append(next(it))
return tuple(result)
def reversed(iterable): def reversed(iterable):
a = list(iterable) a = list(iterable)

File diff suppressed because one or more lines are too long

View File

@ -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)

View File

@ -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)

View File

@ -381,6 +381,21 @@ for x, y in zip(d, e):
# verify that original order and values are retained. # verify that original order and values are retained.
assertEqual(x is y, True) assertEqual(x is y, True)
# https://github.com/pocketpy/pocketpy/issues/447
names = ["Alice", "Bob", "Charlie"]
ages = [25, 30, 35]
cities = ["NY", "LA", "SF"]
result = []
for name, age, city in zip(names, ages, cities):
result.append((name, age, city))
assertEqual(result, [("Alice", 25, "NY"), ("Bob", 30, "LA"), ("Charlie", 35, "SF")])
cities.pop()
result = []
for name, age, city in zip(names, ages, cities):
result.append((name, age, city))
assertEqual(result, [("Alice", 25, "NY"), ("Bob", 30, "LA")])
########### test repr############# ########### test repr#############
d = deque(range(200)) d = deque(range(200))
e = eval(repr(d)) e = eval(repr(d))

View File

@ -187,10 +187,27 @@ DEALINGS IN THE SOFTWARE.
} }
#run-button { #run-button {
padding-left: 10px; padding-left: 20px;
padding-right: 10px; padding-right: 20px;
padding-bottom: 1px;
font-weight: bold; font-weight: bold;
cursor: pointer; cursor: pointer;
background-color: #007bff;
color: #ffffff;
border: none;
border-radius: 4px;
outline: none;
user-select: none;
}
#run-button:hover,
#run-button:focus {
background-color: #0056b3;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
#run-button:active {
background-color: #004085;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
transform: translateY(1px);
} }
#code-editor.hljs { #code-editor.hljs {