From 705dfda89c7795f84419e176e3f861780fbd0fcb Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 23 Apr 2021 16:04:17 +0800 Subject: add a missing global variable check. --- src/yuescript/yue_compiler.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 1cc5284..5f59340 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp @@ -59,7 +59,7 @@ inline std::string s(std::string_view sv) { return std::string(sv); } -const std::string_view version = "0.7.8"sv; +const std::string_view version = "0.7.9"sv; const std::string_view extension = "yue"sv; class YueCompilerImpl { @@ -4411,6 +4411,11 @@ private: void transform_variable_pair(variable_pair_t* pair, str_list& out) { auto name = _parser.toString(pair->name); + if (_config.lintGlobalVariable && !isSolidDefined(name)) { + if (_globals.find(name) == _globals.end()) { + _globals[name] = {pair->name->m_begin.m_line, pair->name->m_begin.m_col}; + } + } out.push_back(name + s(" = "sv) + name); } -- cgit v1.2.3-55-g6feb