From 4827d200604a086e2ad94edb4257c3abc7a3c4fc Mon Sep 17 00:00:00 2001 From: Li Jin Date: Sat, 25 Jan 2020 14:11:25 +0800 Subject: fix more chain value case. --- spec/inputs/existential.moon | 2 +- src/MoonP/moon_compiler.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/inputs/existential.moon b/spec/inputs/existential.moon index e8e2249..f7d5ebd 100644 --- a/spec/inputs/existential.moon +++ b/spec/inputs/existential.moon @@ -17,5 +17,5 @@ with abc?!\func?! if {:x} = a?.if?\then?(123)? @?\function 998 print x -res = b.function\do!\while("OK")\if("def",998)\f? +res = b.function\do!\while?("OK")\if("def",998)\f? print res diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index 020e561..b1770fb 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp @@ -441,16 +441,17 @@ private: if (ast_is(chainValue->items.back())) { return ChainType::EndWithEOP; } + ChainType type = ChainType::Common; for (auto item : chainValue->items.objects()) { if (auto colonChain = ast_cast(item)) { if (ast_is(colonChain->name)) { - return ChainType::HasKeyword; + type = ChainType::HasKeyword; } - } else if (ast_is(item) && item != chainValue->items.back()) { + } else if (ast_is(item)) { return ChainType::HasEOP; } } - return ChainType::Common; + return type; } std::string singleVariableFrom(ChainValue_t* chainValue) { -- cgit v1.2.3-55-g6feb