aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2020-08-05 22:48:01 +0800
committerLi Jin <dragon-fly@qq.com>2020-08-05 22:48:01 +0800
commitab59ed159a87f724c8ae4d2005868337da619662 (patch)
tree3759530867dd20421f9b16330ff1baba5d1871f0
parent8c596dc1efa8a1267c222b168a4de9c8ba254760 (diff)
downloadyuescript-ab59ed159a87f724c8ae4d2005868337da619662.tar.gz
yuescript-ab59ed159a87f724c8ae4d2005868337da619662.tar.bz2
yuescript-ab59ed159a87f724c8ae4d2005868337da619662.zip
fix case for extending class without name.
-rw-r--r--spec/inputs/class.moon3
-rw-r--r--src/MoonP/moon_compiler.cpp4
2 files changed, 5 insertions, 2 deletions
diff --git a/spec/inputs/class.moon b/spec/inputs/class.moon
index 533694e..ca8b58c 100644
--- a/spec/inputs/class.moon
+++ b/spec/inputs/class.moon
@@ -226,4 +226,7 @@ do
226 test = Test! 226 test = Test!
227 test\test! 227 test\test!
228 228
229class extends lapis.Application
230 "/": => json: { status: true }
231
229nil 232nil
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp
index 1d9161b..271bc06 100644
--- a/src/MoonP/moon_compiler.cpp
+++ b/src/MoonP/moon_compiler.cpp
@@ -49,7 +49,7 @@ inline std::string s(std::string_view sv) {
49} 49}
50 50
51const std::string_view version() { 51const std::string_view version() {
52 return "0.4.5"sv; 52 return "0.4.6"sv;
53} 53}
54 54
55// name of table stored in lua registry 55// name of table stored in lua registry
@@ -4117,7 +4117,7 @@ private:
4117 if (!className.empty()) { 4117 if (!className.empty()) {
4118 _buf << ","sv << nll(classDecl) << indent(1) << "__name = "sv << className << (extend ? s(","sv) : Empty) << nll(classDecl); 4118 _buf << ","sv << nll(classDecl) << indent(1) << "__name = "sv << className << (extend ? s(","sv) : Empty) << nll(classDecl);
4119 } else { 4119 } else {
4120 _buf << nll(classDecl); 4120 _buf << (extend ? s(","sv) : Empty) << nll(classDecl);
4121 } 4121 }
4122 if (extend) { 4122 if (extend) {
4123 _buf << indent(1) << "__parent = "sv << parentVar << nll(classDecl); 4123 _buf << indent(1) << "__parent = "sv << parentVar << nll(classDecl);