From 5e1f0afc5df421766f2a1aab0a8f2a50992e1064 Mon Sep 17 00:00:00 2001 From: pikastech Date: Mon, 11 Jul 2022 23:32:30 +0800 Subject: [PATCH] create LST when input tuple --- port/linux/test/parse-test.cpp | 16 ++++++++++++++++ src/PikaVM.c | 9 +++++++-- src/PikaVersion.h | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/port/linux/test/parse-test.cpp b/port/linux/test/parse-test.cpp index 0fdb3638d..37383acd6 100644 --- a/port/linux/test/parse-test.cpp +++ b/port/linux/test/parse-test.cpp @@ -3538,3 +3538,19 @@ TEST(parser, branket_issue4) { EXPECT_EQ(pikaMemNow(), 0); } #endif + +TEST(parser, tuple1) { + pikaMemInfo.heapUsedMax = 0; + Args* buffs = New_strBuff(); + char* lines = "(a,b)\n"; + __platform_printf("%s\n", lines); + char* pikaAsm = Parser_multiLineToAsm(buffs, lines); + __platform_printf("%s", pikaAsm); + EXPECT_STREQ(pikaAsm, + "B0\n" + "1 REF a\n" + "1 REF b\n" + "0 RUN\n"); + args_deinit(buffs); + EXPECT_EQ(pikaMemNow(), 0); +} diff --git a/src/PikaVM.c b/src/PikaVM.c index 0b804b471..237415177 100644 --- a/src/PikaVM.c +++ b/src/PikaVM.c @@ -686,9 +686,14 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self, VMState* vs, char* data) { vs->try_error_code == TRY_STATE_INNER) { sub_try_info.try_state = TRY_STATE_INNER; } - /* return arg directly */ if (strEqu(data, "")) { - return_arg = stack_popArg(&(vs->stack)); + if (VMState_getInputArgNum(vs) < 2) { + /* return arg directly */ + return_arg = stack_popArg(&(vs->stack)); + goto exit; + } + /* create a tuple */ + return_arg = VM_instruction_handler_LST(self, vs, ""); goto exit; } /* return tiny obj */ diff --git a/src/PikaVersion.h b/src/PikaVersion.h index 480cf65ca..7f1c3cb62 100644 --- a/src/PikaVersion.h +++ b/src/PikaVersion.h @@ -2,4 +2,4 @@ #define PIKA_VERSION_MINOR 9 #define PIKA_VERSION_MICRO 0 -#define PIKA_EDIT_TIME "2022/07/11 16:37:09" +#define PIKA_EDIT_TIME "2022/07/11 23:32:26"