From dd64edd58fe25ec74ae5958128cf3f74b0692f3b Mon Sep 17 00:00:00 2001 From: Li Jin Date: Wed, 28 Jan 2026 18:43:14 +0800 Subject: Fixed compiler issues and added 800+ test cases. --- src/yue.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/yue.cpp') diff --git a/src/yue.cpp b/src/yue.cpp index ee4eb38..a30075d 100644 --- a/src/yue.cpp +++ b/src/yue.cpp @@ -201,8 +201,13 @@ static std::string compileFile(const fs::path& file, yue::YueConfig conf, const conf.module = modulePath.string(); if (!workPath.empty()) { auto it = conf.options.find("path"); - if (it == conf.options.end()) { - conf.options["path"] = (workPath / "?.lua"sv).string(); + if (it != conf.options.end()) { + if (!it->second.empty()) { + it->second += ';'; + } + it->second += (fs::path(workPath) / "?.lua"sv).string(); + } else { + conf.options["path"] = (fs::path(workPath) / "?.lua"sv).string(); } } auto result = yue::YueCompiler{YUE_ARGS}.compile(s, conf); @@ -852,7 +857,6 @@ int main(int narg, const char** args) { std::list>> results; for (const auto& file : files) { auto task = async>([=]() { - try { std::ifstream input(file.first, std::ios::in); if (input) { std::string s( @@ -862,7 +866,12 @@ int main(int narg, const char** args) { conf.module = file.first; if (!workPath.empty()) { auto it = conf.options.find("path"); - if (it == conf.options.end()) { + if (it != conf.options.end()) { + if (!it->second.empty()) { + it->second += ';'; + } + it->second += (fs::path(workPath) / "?.lua"sv).string(); + } else { conf.options["path"] = (fs::path(workPath) / "?.lua"sv).string(); } } @@ -942,15 +951,6 @@ int main(int narg, const char** args) { } else { return std::tuple{1, std::string(), "Failed to read file: "s + file.first + '\n'}; } - } catch (const std::length_error& e) { - std::ostringstream buf; - buf << "std::length_error: " << e.what() << " for file: " << file.first << '\n'; - return std::tuple{1, std::string(), buf.str()}; - } catch (const std::exception& e) { - std::ostringstream buf; - buf << "Exception: " << e.what() << " for file: " << file.first << '\n'; - return std::tuple{1, std::string(), buf.str()}; - } }); results.push_back(std::move(task)); } -- cgit v1.2.3-55-g6feb