diff options
author | Li Jin <dragon-fly@qq.com> | 2020-07-17 16:22:11 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2020-07-17 16:22:11 +0800 |
commit | 8ab0038c09a79fa8401bb10b7a31d03ef5380417 (patch) | |
tree | e6f61f25d9e5aae95a05d974938fa7a5fbfd998e /src | |
parent | 7e057d0dd7048d1aa8fbcadb9998902462a384d6 (diff) | |
download | yuescript-8ab0038c09a79fa8401bb10b7a31d03ef5380417.tar.gz yuescript-8ab0038c09a79fa8401bb10b7a31d03ef5380417.tar.bz2 yuescript-8ab0038c09a79fa8401bb10b7a31d03ef5380417.zip |
fixed a missed case for multiline string as table key. reporting use of global variable 'tostring' .
Diffstat (limited to 'src')
-rw-r--r-- | src/MoonP/moon_compiler.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index 1283422..41d29df 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 | ||
51 | const std::string_view version() { | 51 | const std::string_view version() { |
52 | return "0.4.3"sv; | 52 | return "0.4.4"sv; |
53 | } | 53 | } |
54 | 54 | ||
55 | // name of table stored in lua registry | 55 | // name of table stored in lua registry |
@@ -3814,7 +3814,7 @@ private: | |||
3814 | } | 3814 | } |
3815 | case id<Exp_t>(): | 3815 | case id<Exp_t>(): |
3816 | transformExp(static_cast<Exp_t*>(key), temp, ExpUsage::Closure); | 3816 | transformExp(static_cast<Exp_t*>(key), temp, ExpUsage::Closure); |
3817 | temp.back() = s("["sv) + temp.back() + s("]"sv); | 3817 | temp.back() = s(temp.back().front() == '[' ? "[ "sv : "["sv) + temp.back() + s("]"sv); |
3818 | break; | 3818 | break; |
3819 | case id<DoubleString_t>(): | 3819 | case id<DoubleString_t>(): |
3820 | transformDoubleString(static_cast<DoubleString_t*>(key), temp); | 3820 | transformDoubleString(static_cast<DoubleString_t*>(key), temp); |
@@ -3873,10 +3873,19 @@ private: | |||
3873 | temp.push_back(s("\""sv) + str + s("\""sv)); | 3873 | temp.push_back(s("\""sv) + str + s("\""sv)); |
3874 | break; | 3874 | break; |
3875 | } | 3875 | } |
3876 | case id<Exp_t>(): | 3876 | case id<Exp_t>(): { |
3877 | transformExp(static_cast<Exp_t*>(content), temp, ExpUsage::Closure); | 3877 | transformExp(static_cast<Exp_t*>(content), temp, ExpUsage::Closure); |
3878 | temp.back() = s("tostring("sv) + temp.back() + s(")"sv); | 3878 | std::string tostr("tostring"sv); |
3879 | temp.back() = tostr + '(' + temp.back() + s(")"sv); | ||
3880 | if (_config.lintGlobalVariable) { | ||
3881 | if (!isDefined(tostr)) { | ||
3882 | if (_globals.find(tostr) == _globals.end()) { | ||
3883 | _globals[tostr] = {content->m_begin.m_line, content->m_begin.m_col}; | ||
3884 | } | ||
3885 | } | ||
3886 | } | ||
3879 | break; | 3887 | break; |
3888 | } | ||
3880 | default: assert(false); break; | 3889 | default: assert(false); break; |
3881 | } | 3890 | } |
3882 | } | 3891 | } |