From e9926f70a53639c09a5605f71a34ec370395f5a9 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Sun, 15 May 2022 17:26:33 +0800 Subject: fix issue #100. --- src/yuescript/yue_compiler.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index bc046af..469dfea 100755 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp @@ -60,7 +60,7 @@ using namespace parserlib; typedef std::list str_list; -const std::string_view version = "0.10.18"sv; +const std::string_view version = "0.10.19"sv; const std::string_view extension = "yue"sv; class YueCompilerImpl { @@ -2005,6 +2005,9 @@ private: auto value = tab->new_ptr(); value->item.set(simpleValue); auto pairs = destructFromExp(newExp(value, expr)); + if (pairs.empty()) { + throw std::logic_error(_info.errorMessage("expect items to be destructured"sv, tab)); + } destruct.items = std::move(pairs); if (!varDefOnly) { if (*j == nullNode) { @@ -6589,12 +6592,13 @@ private: } void transformImportAs(ImportAs_t* import, str_list& out) { - auto x = import; + ast_node* x = import; if (!import->target) { auto name = moduleNameFrom(import->literal); import->target.set(toAst(name, x)); } if (ast_is(import->target)) { + x = import->target.get(); bool importAllMacro = import->target.is(); std::list> macroPairs; auto newTab = x->new_ptr(); -- cgit v1.2.3-55-g6feb