Skip to content

Commit

Permalink
fix: preceding simple statement in IfStmt should have its own block
Browse files Browse the repository at this point in the history
  • Loading branch information
shenyih0ng committed Apr 16, 2024
1 parent 33d16a4 commit 70f6a20
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/go-slang/goroutine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,14 @@ const Interpreter: {

IfStatement: ({ stmt, cond, cons, alt }: IfStatement, { C, H }) => {
const branchOp: BranchOp = { type: CommandType.BranchOp, cons, alt }
stmt ? C.pushR(...H.allocM([stmt, cond, branchOp])) : C.pushR(...H.allocM([cond, branchOp]))
stmt
? C.push(
H.alloc({
type: NodeType.Block,
statements: [stmt, { type: NodeType.IfStatement, cond, cons, alt }]
})
)
: C.pushR(...H.allocM([cond, branchOp]))
},

ForStatement: (inst: ForStatement, { C, H }) => {
Expand Down

0 comments on commit 70f6a20

Please sign in to comment.