From 82b86397797ecd4d1782ee75abf7933e5d973e3c Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 16 Aug 2022 10:40:36 +0800 Subject: fix a missing argument number check. --- spec/inputs/backcall.yue | 32 ++++++++++++++++++++------------ spec/outputs/backcall.lua | 16 ++++++++++++++++ src/yuescript/yue_compiler.cpp | 9 ++++++--- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/spec/inputs/backcall.yue b/spec/inputs/backcall.yue index d7ed0dd..8aadc71 100644 --- a/spec/inputs/backcall.yue +++ b/spec/inputs/backcall.yue @@ -1,32 +1,32 @@ do - (x)<- map {1,2,3} + (x) <- map {1,2,3} x * 2 do - (x)<- map _,{1,2,3} + (x) <- map _,{1,2,3} x * 2 do - (x)<- filter _, do - (x)<- map _,{1,2,3,4} + (x) <- filter _, do + (x) <- map _,{1,2,3,4} x * 2 x > 2 do - (data)<- http?.get "ajaxtest" + (data) <- http?.get "ajaxtest" body[".result"]\html data - (processed)<- http.post "ajaxprocess", data + (processed) <- http.post "ajaxprocess", data body[".result"]\append processed <- setTimeout 1000 print "done" do <- syncStatus - (err, data="nil")<- loadAsync "file.yue" + (err, data="nil") <- loadAsync "file.yue" if err print err return - (codes)<- compileAsync data + (codes) <- compileAsync data func = loadstring codes func! @@ -42,18 +42,18 @@ do do :result,:msg = do - (data)<- receiveAsync "filename.txt" + (data) <- receiveAsync "filename.txt" print data - (info)<- processAsync data + (info) <- processAsync data check info print result,msg totalSize = (for file in *files - (data)<- loadAsync file + (data) <- loadAsync file addToCache file,data) |> reduce 0,(a,b)-> a+b propA = do - (value)<= property => @_value + (value) <= property => @_value print "old value: #{@_value}" print "new value: #{value}" @_value = value @@ -67,5 +67,13 @@ propB = do alert "hi" +local x, y, z +x = do (a) < -b +x, y, z = do (a) <- b +x, y, z = do (a) <-b + +x = do a <= b +x, y, z = do (a) <= b + nil diff --git a/spec/outputs/backcall.lua b/spec/outputs/backcall.lua index 3a4c5e9..b065388 100644 --- a/spec/outputs/backcall.lua +++ b/spec/outputs/backcall.lua @@ -130,4 +130,20 @@ do end) end alert("hi") +local x, y, z +do + x = (a) < -b +end +do + x, y, z = b(function(a) end) +end +do + x, y, z = b(function(a) end) +end +do + x = a <= b +end +do + x, y, z = b(function(self, a) end) +end return nil diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 868bf90..b730a9f 100755 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp @@ -54,7 +54,7 @@ namespace yue { typedef std::list str_list; -const std::string_view version = "0.14.4"sv; +const std::string_view version = "0.14.5"sv; const std::string_view extension = "yue"sv; class YueCompilerImpl { @@ -1366,7 +1366,10 @@ private: } BREAK_IF(checkValuesLater); auto value = singleValueFrom(values.back()); - BREAK_IF(!value); + if (!value) { + _buf << exprs.size() << " right values expected, got "sv << values.size(); + throw std::logic_error(_info.errorMessage(clearBuf(), values.front())); + } if (auto val = value->item.as()) { switch (val->value->getId()) { case id(): @@ -6974,7 +6977,7 @@ private: for (auto name : import->names.objects()) { switch (name->getId()) { case id(): { - auto var = ast_to(name); + auto var = static_cast(name); { auto callable = toAst(objVar, x); auto dotChainItem = x->new_ptr(); -- cgit v1.2.3-55-g6feb