Skip to content

Commit c78443a

Browse files
committed
Fix jump offsets
1 parent b5c2a7c commit c78443a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/compiler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ func (c *compiler) addConstant(constant interface{}) int {
121121
}
122122

123123
func (c *compiler) patchJump(placeholder int) {
124-
offset := len(c.bytecode) - 1 - placeholder
124+
offset := len(c.bytecode) - placeholder
125125
c.arguments[placeholder-1] = offset
126126
}
127127

128128
func (c *compiler) calcBackwardJump(to int) int {
129-
return len(c.bytecode) - 1 - to
129+
return len(c.bytecode) + 1 - to
130130
}
131131

132132
func (c *compiler) compile(node ast.Node) {

0 commit comments

Comments
 (0)