diff options
author | Li Jin <dragon-fly@qq.com> | 2022-08-16 10:40:36 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-08-16 10:40:36 +0800 |
commit | 82b86397797ecd4d1782ee75abf7933e5d973e3c (patch) | |
tree | 528cbf8a128c94679b63223e6fd16fa8659dbe36 | |
parent | be7fabeef0b6de9b15c2ff34e95794d87042c3bd (diff) | |
download | yuescript-82b86397797ecd4d1782ee75abf7933e5d973e3c.tar.gz yuescript-82b86397797ecd4d1782ee75abf7933e5d973e3c.tar.bz2 yuescript-82b86397797ecd4d1782ee75abf7933e5d973e3c.zip |
fix a missing argument number check.
-rw-r--r-- | spec/inputs/backcall.yue | 32 | ||||
-rw-r--r-- | spec/outputs/backcall.lua | 16 | ||||
-rwxr-xr-x | 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 @@ | |||
1 | do | 1 | do |
2 | (x)<- map {1,2,3} | 2 | (x) <- map {1,2,3} |
3 | x * 2 | 3 | x * 2 |
4 | 4 | ||
5 | do | 5 | do |
6 | (x)<- map _,{1,2,3} | 6 | (x) <- map _,{1,2,3} |
7 | x * 2 | 7 | x * 2 |
8 | 8 | ||
9 | do | 9 | do |
10 | (x)<- filter _, do | 10 | (x) <- filter _, do |
11 | (x)<- map _,{1,2,3,4} | 11 | (x) <- map _,{1,2,3,4} |
12 | x * 2 | 12 | x * 2 |
13 | x > 2 | 13 | x > 2 |
14 | 14 | ||
15 | do | 15 | do |
16 | (data)<- http?.get "ajaxtest" | 16 | (data) <- http?.get "ajaxtest" |
17 | body[".result"]\html data | 17 | body[".result"]\html data |
18 | (processed)<- http.post "ajaxprocess", data | 18 | (processed) <- http.post "ajaxprocess", data |
19 | body[".result"]\append processed | 19 | body[".result"]\append processed |
20 | <- setTimeout 1000 | 20 | <- setTimeout 1000 |
21 | print "done" | 21 | print "done" |
22 | 22 | ||
23 | do | 23 | do |
24 | <- syncStatus | 24 | <- syncStatus |
25 | (err, data="nil")<- loadAsync "file.yue" | 25 | (err, data="nil") <- loadAsync "file.yue" |
26 | if err | 26 | if err |
27 | print err | 27 | print err |
28 | return | 28 | return |
29 | (codes)<- compileAsync data | 29 | (codes) <- compileAsync data |
30 | func = loadstring codes | 30 | func = loadstring codes |
31 | func! | 31 | func! |
32 | 32 | ||
@@ -42,18 +42,18 @@ do | |||
42 | 42 | ||
43 | do | 43 | do |
44 | :result,:msg = do | 44 | :result,:msg = do |
45 | (data)<- receiveAsync "filename.txt" | 45 | (data) <- receiveAsync "filename.txt" |
46 | print data | 46 | print data |
47 | (info)<- processAsync data | 47 | (info) <- processAsync data |
48 | check info | 48 | check info |
49 | print result,msg | 49 | print result,msg |
50 | 50 | ||
51 | totalSize = (for file in *files | 51 | totalSize = (for file in *files |
52 | (data)<- loadAsync file | 52 | (data) <- loadAsync file |
53 | addToCache file,data) |> reduce 0,(a,b)-> a+b | 53 | addToCache file,data) |> reduce 0,(a,b)-> a+b |
54 | 54 | ||
55 | propA = do | 55 | propA = do |
56 | (value)<= property => @_value | 56 | (value) <= property => @_value |
57 | print "old value: #{@_value}" | 57 | print "old value: #{@_value}" |
58 | print "new value: #{value}" | 58 | print "new value: #{value}" |
59 | @_value = value | 59 | @_value = value |
@@ -67,5 +67,13 @@ propB = do | |||
67 | 67 | ||
68 | alert "hi" | 68 | alert "hi" |
69 | 69 | ||
70 | local x, y, z | ||
71 | x = do (a) < -b | ||
72 | x, y, z = do (a) <- b | ||
73 | x, y, z = do (a) <-b | ||
74 | |||
75 | x = do a <= b | ||
76 | x, y, z = do (a) <= b | ||
77 | |||
70 | nil | 78 | nil |
71 | 79 | ||
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 | |||
130 | end) | 130 | end) |
131 | end | 131 | end |
132 | alert("hi") | 132 | alert("hi") |
133 | local x, y, z | ||
134 | do | ||
135 | x = (a) < -b | ||
136 | end | ||
137 | do | ||
138 | x, y, z = b(function(a) end) | ||
139 | end | ||
140 | do | ||
141 | x, y, z = b(function(a) end) | ||
142 | end | ||
143 | do | ||
144 | x = a <= b | ||
145 | end | ||
146 | do | ||
147 | x, y, z = b(function(self, a) end) | ||
148 | end | ||
133 | return nil | 149 | 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 { | |||
54 | 54 | ||
55 | typedef std::list<std::string> str_list; | 55 | typedef std::list<std::string> str_list; |
56 | 56 | ||
57 | const std::string_view version = "0.14.4"sv; | 57 | const std::string_view version = "0.14.5"sv; |
58 | const std::string_view extension = "yue"sv; | 58 | const std::string_view extension = "yue"sv; |
59 | 59 | ||
60 | class YueCompilerImpl { | 60 | class YueCompilerImpl { |
@@ -1366,7 +1366,10 @@ private: | |||
1366 | } | 1366 | } |
1367 | BREAK_IF(checkValuesLater); | 1367 | BREAK_IF(checkValuesLater); |
1368 | auto value = singleValueFrom(values.back()); | 1368 | auto value = singleValueFrom(values.back()); |
1369 | BREAK_IF(!value); | 1369 | if (!value) { |
1370 | _buf << exprs.size() << " right values expected, got "sv << values.size(); | ||
1371 | throw std::logic_error(_info.errorMessage(clearBuf(), values.front())); | ||
1372 | } | ||
1370 | if (auto val = value->item.as<SimpleValue_t>()) { | 1373 | if (auto val = value->item.as<SimpleValue_t>()) { |
1371 | switch (val->value->getId()) { | 1374 | switch (val->value->getId()) { |
1372 | case id<If_t>(): | 1375 | case id<If_t>(): |
@@ -6974,7 +6977,7 @@ private: | |||
6974 | for (auto name : import->names.objects()) { | 6977 | for (auto name : import->names.objects()) { |
6975 | switch (name->getId()) { | 6978 | switch (name->getId()) { |
6976 | case id<Variable_t>(): { | 6979 | case id<Variable_t>(): { |
6977 | auto var = ast_to<Variable_t>(name); | 6980 | auto var = static_cast<Variable_t*>(name); |
6978 | { | 6981 | { |
6979 | auto callable = toAst<Callable_t>(objVar, x); | 6982 | auto callable = toAst<Callable_t>(objVar, x); |
6980 | auto dotChainItem = x->new_ptr<DotChainItem_t>(); | 6983 | auto dotChainItem = x->new_ptr<DotChainItem_t>(); |