aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-01-22 17:53:34 +0800
committerLi Jin <dragon-fly@qq.com>2021-01-22 17:53:34 +0800
commitf61b96675547c8bf40c7f646e3766f4139efd927 (patch)
tree57aafd430ad65f6cba85968599568a8c8d9395c0
parent6dc11dccc6c8147b5b71c86be7e458eebc35f8c5 (diff)
downloadyuescript-f61b96675547c8bf40c7f646e3766f4139efd927.tar.gz
yuescript-f61b96675547c8bf40c7f646e3766f4139efd927.tar.bz2
yuescript-f61b96675547c8bf40c7f646e3766f4139efd927.zip
fix issue #36
-rw-r--r--spec/inputs/funcs.mp1
-rw-r--r--spec/inputs/macro.mp2
-rw-r--r--src/MoonP/moon_compiler.cpp11
3 files changed, 9 insertions, 5 deletions
diff --git a/spec/inputs/funcs.mp b/spec/inputs/funcs.mp
index 4176e33..0e45ff1 100644
--- a/spec/inputs/funcs.mp
+++ b/spec/inputs/funcs.mp
@@ -46,6 +46,7 @@ _ = (x = if something then yeah else no) ->
46something = (hello=100, world=(x=[[yeah cool]])-> print "eat rice") -> 46something = (hello=100, world=(x=[[yeah cool]])-> print "eat rice") ->
47 print hello 47 print hello
48 48
49_ = () =>
49_ = (x, y) => 50_ = (x, y) =>
50_ = (@x, @y) => 51_ = (@x, @y) =>
51_ = (x=1) => 52_ = (x=1) =>
diff --git a/spec/inputs/macro.mp b/spec/inputs/macro.mp
index fafa522..be88a3f 100644
--- a/spec/inputs/macro.mp
+++ b/spec/inputs/macro.mp
@@ -110,7 +110,7 @@ do
110 a += $get_inner_hygienic! 110 a += $get_inner_hygienic!
111 print a 111 print a
112 112
113macro lua lua = (codes)-> "#{codes}" 113macro lua lua = (codes)-> codes
114 114
115x = 0 115x = 0
116 116
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp
index d49cf14..e8649ae 100644
--- a/src/MoonP/moon_compiler.cpp
+++ b/src/MoonP/moon_compiler.cpp
@@ -53,7 +53,7 @@ inline std::string s(std::string_view sv) {
53 return std::string(sv); 53 return std::string(sv);
54} 54}
55 55
56const std::string_view version = "0.4.22"sv; 56const std::string_view version = "0.4.23"sv;
57const std::string_view extension = "mp"sv; 57const std::string_view extension = "mp"sv;
58 58
59class MoonCompilerImpl { 59class MoonCompilerImpl {
@@ -1877,9 +1877,12 @@ private:
1877 auto& args = *it; 1877 auto& args = *it;
1878 auto& initArgs = *(++it); 1878 auto& initArgs = *(++it);
1879 auto& bodyCodes = *(++it); 1879 auto& bodyCodes = *(++it);
1880 _buf << "function("sv << 1880 _buf << "function("sv;
1881 (isFatArrow ? s("self, "sv) : Empty) << 1881 if (isFatArrow) {
1882 args << ')'; 1882 _buf << "self"sv;
1883 if (!args.empty()) _buf << ", "sv;
1884 }
1885 _buf << args << ')';
1883 if (!initArgs.empty() || !bodyCodes.empty()) { 1886 if (!initArgs.empty() || !bodyCodes.empty()) {
1884 _buf << nlr(argsDef) << initArgs << bodyCodes; 1887 _buf << nlr(argsDef) << initArgs << bodyCodes;
1885 popScope(); 1888 popScope();