From 7c230c3d12fe7f0b8f7222b966ff7a6793795dfb Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Mon, 18 Jan 2021 20:45:07 +0900 Subject: [PATCH] Fixes --- README.md | 4 ++-- compiler.c | 1 + vm.c | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c2b0f42..3fcf191 100644 --- a/README.md +++ b/README.md @@ -309,7 +309,7 @@ Default arguments can be specified as follows: def greet(name="world"): print("Hello, " + name + "!") greet() -gree("user") +greet("user") # → Hello, world! # Hello, user! ``` @@ -882,7 +882,7 @@ As in the _Loops_ section above, an iterator may return a series of tuples which ```py class TupleGenerator: def __iter__(): - let up = 0, down = 0, limit = 5 + let up, down, limit = 0, 0, 5 def _(): if limit-- == 0: return _ return (up++,down--) diff --git a/compiler.c b/compiler.c index c907fa5..ede7ac9 100644 --- a/compiler.c +++ b/compiler.c @@ -2409,6 +2409,7 @@ KrkFunction * krk_compile(const char * src, int newScope, char * fileName) { string(parser.previous.type == TOKEN_BIG_STRING); krk_attachNamedObject(&vm.module->fields, "__doc__", (KrkObj*)AS_STRING(currentChunk()->constants.values[currentChunk()->constants.count-1])); + emitByte(OP_POP); /* string() actually put an instruction for that, pop its result */ consume(TOKEN_EOL,"Garbage after docstring"); } else { krk_attachNamedValue(&vm.module->fields, "__doc__", NONE_VAL()); diff --git a/vm.c b/vm.c index e4fe349..52b1322 100644 --- a/vm.c +++ b/vm.c @@ -2053,8 +2053,8 @@ static int charIn(char c, const char * str) { */ static KrkValue _string_strip_shared(int argc, KrkValue argv[], int which) { if (!IS_STRING(argv[0])) return NONE_VAL(); - if (AS_STRING(argv[0])->type != KRK_STRING_ASCII) { - krk_runtimeError(vm.exceptions.notImplementedError, "str.strip() not implemented for Unicode strings"); + if (argc > 1 && IS_STRING(argv[1]) && AS_STRING(argv[1])->type != KRK_STRING_ASCII) { + krk_runtimeError(vm.exceptions.notImplementedError, "str.strip() not implemented for Unicode strip lists"); return NONE_VAL(); } size_t start = 0;