commit 8e8866f786c55049f5b74fbe5d63feaa481061c0 from: Sergey Bronnikov date: Tue Jan 30 10:40:44 2024 UTC test/fuzz: fix errors "ambiguous syntax" Running of automatically generated Lua programs sometimes failed with an error like "ambiguous syntax (function call x new statement)" (0.3%). The patch fixes these errors. NO_CHANGELOG=testing NO_DOC=testing NO_TEST=testing commit - b933a74b0bf03995b5c2074eb61b9cc3b5b780c4 commit + 8e8866f786c55049f5b74fbe5d63feaa481061c0 blob - 4d5df2d432da5d1478b1cdc6eaf7c7bd2bcbead9 blob + 003658e7a8ce2f9b1f539c44e317c12de83b3dc3 --- test/fuzz/luaL_loadbuffer/serializer.cc +++ test/fuzz/luaL_loadbuffer/serializer.cc @@ -452,7 +452,15 @@ PROTO_TOSTRING(LastStatement, laststat) break; } - if (!laststat_str.empty() && laststat.has_semicolon()) + /* + * Add a semicolon when last statement is not empty + * to avoid errors like: + * + * + * (nil):Name0() + * (nil)() -- ambiguous syntax (function call x new statement) near '(' + */ + if (!laststat_str.empty()) laststat_str += "; "; return laststat_str; @@ -522,8 +530,15 @@ PROTO_TOSTRING(Statement, stat) break; } - if (stat.has_semicolon()) - stat_str += "; "; + /* + * Always add a semicolon regardless of grammar + * to avoid errors like: + * + * + * (nil):Name0() + * (nil)() -- ambiguous syntax (function call x new statement) near '(' + */ + stat_str += "; "; return stat_str; }