aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-04-02 09:50:09 +0800
committerLi Jin <dragon-fly@qq.com>2022-04-02 09:50:09 +0800
commit1f1af19560054b47935151f298ff06ff2cad5ef9 (patch)
tree0c051c0b137794eb15c8b87f7602c720ed0fe397
parentca1ed557769352c0ac0ca7804dd25e18c1fdf2e1 (diff)
downloadyuescript-1f1af19560054b47935151f298ff06ff2cad5ef9.tar.gz
yuescript-1f1af19560054b47935151f298ff06ff2cad5ef9.tar.bz2
yuescript-1f1af19560054b47935151f298ff06ff2cad5ef9.zip
try fixing overriding issue mentioned in issue #84.
-rw-r--r--spec/outputs/class.lua2
-rwxr-xr-xsrc/yuescript/yue_compiler.cpp4
2 files changed, 3 insertions, 3 deletions
diff --git a/spec/outputs/class.lua b/spec/outputs/class.lua
index 85845d3..929c243 100644
--- a/spec/outputs/class.lua
+++ b/spec/outputs/class.lua
@@ -1033,7 +1033,7 @@ do
1033 for _index_0 = 1, #_list_0 do 1033 for _index_0 = 1, #_list_0 do
1034 local _mixin_0 = _list_0[_index_0] 1034 local _mixin_0 = _list_0[_index_0]
1035 for _key_0, _val_0 in pairs(_mixin_0.__base) do 1035 for _key_0, _val_0 in pairs(_mixin_0.__base) do
1036 if not _key_0:match("^__") then 1036 if not _key_0:match("^__") and _base_0[_key_0] == nil then
1037 _base_0[_key_0] = _val_0 1037 _base_0[_key_0] = _val_0
1038 end 1038 end
1039 end 1039 end
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp
index 26a8c5a..3720915 100755
--- a/src/yuescript/yue_compiler.cpp
+++ b/src/yuescript/yue_compiler.cpp
@@ -60,7 +60,7 @@ using namespace parserlib;
60 60
61typedef std::list<std::string> str_list; 61typedef std::list<std::string> str_list;
62 62
63const std::string_view version = "0.10.8"sv; 63const std::string_view version = "0.10.9"sv;
64const std::string_view extension = "yue"sv; 64const std::string_view extension = "yue"sv;
65 65
66class YueCompilerImpl { 66class YueCompilerImpl {
@@ -5344,7 +5344,7 @@ private:
5344 auto mixins = _parser.toString(classDecl->mixes); 5344 auto mixins = _parser.toString(classDecl->mixes);
5345 _buf << "for "sv << mixin << " in *{"sv << mixins << "}\n"sv; 5345 _buf << "for "sv << mixin << " in *{"sv << mixins << "}\n"sv;
5346 _buf << "\tfor "sv << key << ',' << val << " in pairs "sv << mixin << ".__base\n"sv; 5346 _buf << "\tfor "sv << key << ',' << val << " in pairs "sv << mixin << ".__base\n"sv;
5347 _buf << "\t\t"sv << baseVar << '[' << key << "]="sv << val << " if not "sv << key << "\\match\"^__\""sv; 5347 _buf << "\t\t"sv << baseVar << '[' << key << "]="sv << val << " if not "sv << key << "\\match\"^__\" and "sv << baseVar << '[' << key << "] == nil"sv;
5348 transformBlock(toAst<Block_t>(clearBuf(), x), temp, ExpUsage::Common); 5348 transformBlock(toAst<Block_t>(clearBuf(), x), temp, ExpUsage::Common);
5349 } 5349 }
5350 temp.push_back(indent() + baseVar + ".__index = "s + baseVar + nll(classDecl)); 5350 temp.push_back(indent() + baseVar + ".__index = "s + baseVar + nll(classDecl));