From 3cda6dd3f404f666130d60dca876f8633d00752a Mon Sep 17 00:00:00 2001 From: waffle Date: Wed, 27 Aug 2025 18:00:47 -0400 Subject: [PATCH 1/3] fix stackoverflow in Debug configuration building and running Luau.CLI.Test.exe in the Debug configuration would stack overflow, this solves that --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 126130182..18b60f87d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -194,6 +194,11 @@ if(MSVC AND LUAU_BUILD_CLI) set_target_properties(Luau.Repl.CLI PROPERTIES LINK_FLAGS_DEBUG /STACK:2097152) endif() +if(MSVC AND LUAU_BUILD_TESTS) + # Luau.CLI.Test also needs increased stack size in Debug due to complex repl functionality and metatable traversals + set_target_properties(Luau.CLI.Test PROPERTIES LINK_FLAGS_DEBUG /STACK:2097152) +endif() + # embed .natvis inside the library debug information if(MSVC) target_link_options(Luau.Ast INTERFACE /NATVIS:${CMAKE_CURRENT_SOURCE_DIR}/tools/natvis/Ast.natvis) From 932877657c43f58e66430e5d91989ce4249d0f80 Mon Sep 17 00:00:00 2001 From: waffle Date: Thu, 28 Aug 2025 03:13:59 -0400 Subject: [PATCH 2/3] luau-analyze.exe improve error/success messaging, fix path resolution adds output statements when files are not found, no argument is given, or analysis succeeds. also fixes a prior bug where it would fail to analyze files in any other folder. Since success and failure is output explicitly, failure to analyze can no longer be confused as not having any errors. --- CLI/src/Analyze.cpp | 84 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 3 deletions(-) diff --git a/CLI/src/Analyze.cpp b/CLI/src/Analyze.cpp index 1a2cafb4f..276a563bd 100644 --- a/CLI/src/Analyze.cpp +++ b/CLI/src/Analyze.cpp @@ -123,7 +123,9 @@ static bool reportModuleResult(Luau::Frontend& frontend, const Luau::ModuleName& static void displayHelp(const char* argv0) { - printf("Usage: %s [--mode] [options] [file list]\n", argv0); + printf("Usage: %s [--mode] [options] [files or directories...]\n", argv0); + printf(" - Inputs may be files or directories; directories are scanned recursively for .lua/.luau files.\n"); + printf(" - Use '-' to read a single script from stdin.\n"); printf("\n"); printf("Available modes:\n"); printf(" omitted: typecheck and lint input files\n"); @@ -405,8 +407,79 @@ int main(int argc, char** argv) std::vector files = getSourceFiles(argc, argv); + // Check if no input files were provided + if (files.empty()) + { + fprintf(stderr, "Error: No Lua/Luau source files found in inputs\n"); + fprintf(stderr, "Usage: %s [--mode] [options] [files or directories...]\n", argv[0]); + fprintf(stderr, "Hint: Provide .lua/.luau files or directories containing them, or use '-' for stdin\n"); + return 1; + } + + // failed: number of invalid inputs detected during validation + int failed = 0; + + // Track stdin ("-") usage and its normalized pseudo-path (skip when queuing). + bool usedStdin = false; + std::string stdinNormalized = normalizePath("-"); + + for (int i = 1; i < argc; ++i) + { + // Skip options (arguments starting with - that aren't just -) + if (argv[i][0] == '-' && argv[i][1] != '\0') + continue; + + std::string originalArg = argv[i]; + + // Special case: "-" means read from stdin (validated here, queued later as "-") + if (originalArg == "-") + { + usedStdin = true; + continue; + } + + std::string normalized = normalizePath(originalArg); + + // Validate inputs: + // - If .lua/.luau file is specified, it must exist as a file + // - Directories are accepted (expanded by getSourceFiles) + // If the argument has a known Luau/Lua extension, ensure it exists as a file. + if (hasFileExtension(normalized, std::vector{".lua", ".luau"})) + { + if (!isFile(normalized)) + { + fprintf(stderr, "Error: %s: No such file or directory\n", normalized.c_str()); + failed++; + } + continue; + } + + if (isDirectory(normalized)) + continue; + + if (!isFile(normalized)) + { + fprintf(stderr, "Error: %s: No such file or directory\n", normalized.c_str()); + failed++; + continue; + } + + } + + + // Queue files expanded from directories and file arguments for (const std::string& path : files) + { + // Skip the normalized stdin pseudo-path only if '-' was actually requested; stdin is queued separately + if (usedStdin && path == stdinNormalized) + continue; + frontend.queueModuleCheck(path); + } + + // Queue stdin if it was explicitly requested + if (usedStdin) + frontend.queueModuleCheck("-"); std::vector checkedModules; @@ -446,8 +519,6 @@ int main(int argc, char** argv) return 1; } - int failed = 0; - for (const Luau::ModuleName& name : checkedModules) failed += !reportModuleResult(frontend, name, format, annotate); @@ -462,5 +533,12 @@ int main(int argc, char** argv) if (format == ReportFormat::Luacheck) return 0; else + { + if (failed == 0 && !checkedModules.empty() && !annotate) + { + // Print success banner only for interactive runs (not --annotate/luacheck). + printf("Analysis completed successfully\n"); + } return failed ? 1 : 0; + } } From 3ba612cf77c4afaf276e1c1b9e528f9d12dcdfb5 Mon Sep 17 00:00:00 2001 From: waffle Date: Thu, 28 Aug 2025 13:12:03 -0400 Subject: [PATCH 3/3] Revert "luau-analyze.exe improve error/success messaging, fix path resolution" This reverts commit 932877657c43f58e66430e5d91989ce4249d0f80. --- CLI/src/Analyze.cpp | 84 ++------------------------------------------- 1 file changed, 3 insertions(+), 81 deletions(-) diff --git a/CLI/src/Analyze.cpp b/CLI/src/Analyze.cpp index 276a563bd..1a2cafb4f 100644 --- a/CLI/src/Analyze.cpp +++ b/CLI/src/Analyze.cpp @@ -123,9 +123,7 @@ static bool reportModuleResult(Luau::Frontend& frontend, const Luau::ModuleName& static void displayHelp(const char* argv0) { - printf("Usage: %s [--mode] [options] [files or directories...]\n", argv0); - printf(" - Inputs may be files or directories; directories are scanned recursively for .lua/.luau files.\n"); - printf(" - Use '-' to read a single script from stdin.\n"); + printf("Usage: %s [--mode] [options] [file list]\n", argv0); printf("\n"); printf("Available modes:\n"); printf(" omitted: typecheck and lint input files\n"); @@ -407,79 +405,8 @@ int main(int argc, char** argv) std::vector files = getSourceFiles(argc, argv); - // Check if no input files were provided - if (files.empty()) - { - fprintf(stderr, "Error: No Lua/Luau source files found in inputs\n"); - fprintf(stderr, "Usage: %s [--mode] [options] [files or directories...]\n", argv[0]); - fprintf(stderr, "Hint: Provide .lua/.luau files or directories containing them, or use '-' for stdin\n"); - return 1; - } - - // failed: number of invalid inputs detected during validation - int failed = 0; - - // Track stdin ("-") usage and its normalized pseudo-path (skip when queuing). - bool usedStdin = false; - std::string stdinNormalized = normalizePath("-"); - - for (int i = 1; i < argc; ++i) - { - // Skip options (arguments starting with - that aren't just -) - if (argv[i][0] == '-' && argv[i][1] != '\0') - continue; - - std::string originalArg = argv[i]; - - // Special case: "-" means read from stdin (validated here, queued later as "-") - if (originalArg == "-") - { - usedStdin = true; - continue; - } - - std::string normalized = normalizePath(originalArg); - - // Validate inputs: - // - If .lua/.luau file is specified, it must exist as a file - // - Directories are accepted (expanded by getSourceFiles) - // If the argument has a known Luau/Lua extension, ensure it exists as a file. - if (hasFileExtension(normalized, std::vector{".lua", ".luau"})) - { - if (!isFile(normalized)) - { - fprintf(stderr, "Error: %s: No such file or directory\n", normalized.c_str()); - failed++; - } - continue; - } - - if (isDirectory(normalized)) - continue; - - if (!isFile(normalized)) - { - fprintf(stderr, "Error: %s: No such file or directory\n", normalized.c_str()); - failed++; - continue; - } - - } - - - // Queue files expanded from directories and file arguments for (const std::string& path : files) - { - // Skip the normalized stdin pseudo-path only if '-' was actually requested; stdin is queued separately - if (usedStdin && path == stdinNormalized) - continue; - frontend.queueModuleCheck(path); - } - - // Queue stdin if it was explicitly requested - if (usedStdin) - frontend.queueModuleCheck("-"); std::vector checkedModules; @@ -519,6 +446,8 @@ int main(int argc, char** argv) return 1; } + int failed = 0; + for (const Luau::ModuleName& name : checkedModules) failed += !reportModuleResult(frontend, name, format, annotate); @@ -533,12 +462,5 @@ int main(int argc, char** argv) if (format == ReportFormat::Luacheck) return 0; else - { - if (failed == 0 && !checkedModules.empty() && !annotate) - { - // Print success banner only for interactive runs (not --annotate/luacheck). - printf("Analysis completed successfully\n"); - } return failed ? 1 : 0; - } }