diff options
| author | Li Jin <dragon-fly@qq.com> | 2023-05-17 15:05:25 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2023-05-17 15:05:25 +0800 |
| commit | 0c589d36fadba92d547fc6a93a2d5494d4d51981 (patch) | |
| tree | 7119e7833a06e32c48a20865a1d93f22d55a52a9 /src/yuescript/yue_compiler.cpp | |
| parent | bfdbb6a93bb4cdb9754516bf19d091aff16c6c83 (diff) | |
| download | yuescript-0c589d36fadba92d547fc6a93a2d5494d4d51981.tar.gz yuescript-0c589d36fadba92d547fc6a93a2d5494d4d51981.tar.bz2 yuescript-0c589d36fadba92d547fc6a93a2d5494d4d51981.zip | |
added missing metamethod names check.
Diffstat (limited to '')
| -rw-r--r-- | src/yuescript/yue_compiler.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index b131eff..e97ec9f 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
| @@ -72,7 +72,7 @@ static std::unordered_set<std::string> Metamethods = { | |||
| 72 | "close"s // Lua 5.4 | 72 | "close"s // Lua 5.4 |
| 73 | }; | 73 | }; |
| 74 | 74 | ||
| 75 | const std::string_view version = "0.16.4"sv; | 75 | const std::string_view version = "0.16.5"sv; |
| 76 | const std::string_view extension = "yue"sv; | 76 | const std::string_view extension = "yue"sv; |
| 77 | 77 | ||
| 78 | class CompileError : public std::logic_error { | 78 | class CompileError : public std::logic_error { |
| @@ -4638,7 +4638,9 @@ private: | |||
| 4638 | auto meta = colon->name.to<Metamethod_t>(); | 4638 | auto meta = colon->name.to<Metamethod_t>(); |
| 4639 | switch (meta->item->getId()) { | 4639 | switch (meta->item->getId()) { |
| 4640 | case id<Name_t>(): { | 4640 | case id<Name_t>(): { |
| 4641 | auto newColon = toAst<ColonChainItem_t>("\\__"s + _parser.toString(meta->item), x); | 4641 | auto name = _parser.toString(meta->item); |
| 4642 | checkMetamethod(name, meta->item); | ||
| 4643 | auto newColon = toAst<ColonChainItem_t>("\\__"s + name, x); | ||
| 4642 | chain->items.push_back(newColon); | 4644 | chain->items.push_back(newColon); |
| 4643 | break; | 4645 | break; |
| 4644 | } | 4646 | } |
| @@ -4731,6 +4733,8 @@ private: | |||
| 4731 | auto meta = dot->name.to<Metamethod_t>(); | 4733 | auto meta = dot->name.to<Metamethod_t>(); |
| 4732 | switch (meta->item->getId()) { | 4734 | switch (meta->item->getId()) { |
| 4733 | case id<Name_t>(): { | 4735 | case id<Name_t>(): { |
| 4736 | auto name = _parser.toString(meta->item); | ||
| 4737 | checkMetamethod(name, meta->item); | ||
| 4734 | auto newDot = toAst<DotChainItem_t>(".__"s + _parser.toString(meta->item), x); | 4738 | auto newDot = toAst<DotChainItem_t>(".__"s + _parser.toString(meta->item), x); |
| 4735 | chain->items.push_back(newDot); | 4739 | chain->items.push_back(newDot); |
| 4736 | break; | 4740 | break; |
