From 810a570779d6621770fea8c25fabff6c2f5d57bd Mon Sep 17 00:00:00 2001 From: Vurv <56230599+Vurv78@users.noreply.github.com> Date: Sat, 14 Oct 2023 15:51:46 -0700 Subject: [PATCH] Fix do while Test wasn't adequate and I didn't pass an extra value to the node data --- data/expression2/tests/runtime/base/loops/while.txt | 7 +++++++ lua/entities/gmod_wire_expression2/base/parser.lua | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/data/expression2/tests/runtime/base/loops/while.txt b/data/expression2/tests/runtime/base/loops/while.txt index 0abd007a26..d48457ca6f 100644 --- a/data/expression2/tests/runtime/base/loops/while.txt +++ b/data/expression2/tests/runtime/base/loops/while.txt @@ -16,6 +16,13 @@ do { assert(Num == 1000) +local Ran = 0 +do { + Ran = 1 +} while (0) + +assert(Ran) + Calls = 1 Inc = 1 function number calls() { diff --git a/lua/entities/gmod_wire_expression2/base/parser.lua b/lua/entities/gmod_wire_expression2/base/parser.lua index 112ee2713d..8d15fb017e 100644 --- a/lua/entities/gmod_wire_expression2/base/parser.lua +++ b/lua/entities/gmod_wire_expression2/base/parser.lua @@ -520,7 +520,7 @@ function Parser:Stmt() if self:Consume(TokenVariant.Keyword, Keyword.Do) then local trace, block = self:Prev().trace, self:Block() self:Assert( self:Consume(TokenVariant.Keyword, Keyword.While), "while expected after do and code block (do {...} )") - return Node.new(NodeVariant.While, { self:Condition(), block }, trace:stitch(self:Prev().trace)) + return Node.new(NodeVariant.While, { self:Condition(), block, true }, trace:stitch(self:Prev().trace)) end -- Event