diff options
Diffstat (limited to 'src/MoonP/moon_compiler.cpp')
-rw-r--r-- | src/MoonP/moon_compiler.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index 64152cf..a39bfd0 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp | |||
@@ -32,7 +32,7 @@ inline std::string s(std::string_view sv) { | |||
32 | } | 32 | } |
33 | 33 | ||
34 | const char* moonScriptVersion() { | 34 | const char* moonScriptVersion() { |
35 | return "0.5.0-r0.1.3"; | 35 | return "0.5.0-r0.1.4"; |
36 | } | 36 | } |
37 | 37 | ||
38 | class MoonCompilerImpl { | 38 | class MoonCompilerImpl { |
@@ -1516,7 +1516,10 @@ private: | |||
1516 | } | 1516 | } |
1517 | bool findPlaceHolder = false; | 1517 | bool findPlaceHolder = false; |
1518 | for (auto a : args->objects()) { | 1518 | for (auto a : args->objects()) { |
1519 | bool lintGlobal = _config.lintGlobalVariable; | ||
1520 | _config.lintGlobalVariable = false; | ||
1519 | auto name = singleVariableFrom(a); | 1521 | auto name = singleVariableFrom(a); |
1522 | _config.lintGlobalVariable = lintGlobal; | ||
1520 | if (name == "_"sv) { | 1523 | if (name == "_"sv) { |
1521 | if (!findPlaceHolder) { | 1524 | if (!findPlaceHolder) { |
1522 | args->swap(a, arg); | 1525 | args->swap(a, arg); |
@@ -1747,10 +1750,29 @@ private: | |||
1747 | } | 1750 | } |
1748 | if (isChainValueCall(backcall->value)) { | 1751 | if (isChainValueCall(backcall->value)) { |
1749 | auto last = backcall->value->items.back(); | 1752 | auto last = backcall->value->items.back(); |
1750 | if (auto invoke = ast_cast<Invoke_t>(last)) { | 1753 | _ast_list* args = nullptr; |
1751 | invoke->args.push_back(arg); | 1754 | if (auto invoke = ast_cast<InvokeArgs_t>(last)) { |
1755 | args = &invoke->args; | ||
1752 | } else { | 1756 | } else { |
1753 | ast_to<InvokeArgs_t>(last)->args.push_back(arg); | 1757 | args = &(ast_to<Invoke_t>(last)->args); |
1758 | } | ||
1759 | bool findPlaceHolder = false; | ||
1760 | for (auto a : args->objects()) { | ||
1761 | bool lintGlobal = _config.lintGlobalVariable; | ||
1762 | _config.lintGlobalVariable = false; | ||
1763 | auto name = singleVariableFrom(a); | ||
1764 | _config.lintGlobalVariable = lintGlobal; | ||
1765 | if (name == "_"sv) { | ||
1766 | if (!findPlaceHolder) { | ||
1767 | args->swap(a, arg); | ||
1768 | findPlaceHolder = true; | ||
1769 | } else { | ||
1770 | throw std::logic_error(_info.errorMessage("backcall placeholder can be used only in one place."sv, a)); | ||
1771 | } | ||
1772 | } | ||
1773 | } | ||
1774 | if (!findPlaceHolder) { | ||
1775 | args->push_back(arg); | ||
1754 | } | 1776 | } |
1755 | } else { | 1777 | } else { |
1756 | auto invoke = x->new_ptr<Invoke_t>(); | 1778 | auto invoke = x->new_ptr<Invoke_t>(); |