Skip to content

Commit

Permalink
Fix do while
Browse files Browse the repository at this point in the history
Test wasn't adequate and I didn't pass an extra value to the node data
  • Loading branch information
Vurv78 committed Oct 14, 2023
1 parent 59ca86e commit 810a570
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions data/expression2/tests/runtime/base/loops/while.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion lua/entities/gmod_wire_expression2/base/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 810a570

Please sign in to comment.