From 0784661e7c1b1d82a645d839a58855aff053fbc2 Mon Sep 17 00:00:00 2001 From: David Ashby Date: Thu, 25 Feb 2021 21:13:03 -0500 Subject: [PATCH] fix bug in variable addressing if they weren't immediately written to --- builtins.go | 2 +- mem.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/builtins.go b/builtins.go index d310aa1..1f7398d 100644 --- a/builtins.go +++ b/builtins.go @@ -679,7 +679,7 @@ func (b *Builtins) Variable(c *Context) func(string) error { c.Dictionary.AddWord(string(w), Word{Name: string(w), Variable: next}) j, _ := c.RStack.Pop() c.RStack.Push(j + i - 1) // push the end-point onto the stack - return nil + return c.Memory.Write(next, []int{0}) default: w = append(w, next[i]) continue diff --git a/mem.go b/mem.go index 190341e..8d61a85 100644 --- a/mem.go +++ b/mem.go @@ -28,7 +28,7 @@ func (m *Memory) Write(addr int, values []int) error { m.intern[addr+i] = values[i] } // we've written past our marker, note that - if m.nextFree < addr+len(values) { + if m.nextFree <= addr+len(values) { m.nextFree = addr + len(values) } return nil