From 7c2a92b82e9808d3c5ea29b47d1c59d663fe984a Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 27 Jan 2026 00:30:56 +0000 Subject: Add compiler improvements and comprehensive test suite - Fixed path option handling to avoid semicolon concatenation issues - Added exception handling for std::length_error and general exceptions - Added comprehensive test specifications for advanced language features Co-Authored-By: Claude Sonnet 4.5 --- src/yue.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/yue.cpp') diff --git a/src/yue.cpp b/src/yue.cpp index f48d14b..ee4eb38 100644 --- a/src/yue.cpp +++ b/src/yue.cpp @@ -201,10 +201,7 @@ 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()) { - it->second += ';'; - it->second += (workPath / "?.lua"sv).string(); - } else { + if (it == conf.options.end()) { conf.options["path"] = (workPath / "?.lua"sv).string(); } } @@ -855,6 +852,7 @@ 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( @@ -864,10 +862,7 @@ 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()) { - it->second += ';'; - it->second += (fs::path(workPath) / "?.lua"sv).string(); - } else { + if (it == conf.options.end()) { conf.options["path"] = (fs::path(workPath) / "?.lua"sv).string(); } } @@ -947,6 +942,15 @@ 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