Ignore load request on same level in state

This commit is contained in:
lash 2023-04-03 07:34:09 +01:00
parent a0f7ad5c80
commit 5a63b24ec1
Signed by untrusted user who does not match committer: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 9 additions and 11 deletions

View File

@ -38,17 +38,6 @@ func(en *Engine) Init(sym string, ctx context.Context) error {
if err != nil {
return err
}
// location := en.st.Where()
// code, err := en.rs.GetCode(location)
// if err != nil {
// return err
// }
// if len(code) == 0 {
// return fmt.Errorf("no code found at resource %s", en.rs)
// }
//
// code, err = vm.Run(code, en.st, en.rs, ctx)
//
en.st.SetCode(b)
return nil
}

View File

@ -238,6 +238,10 @@ func(st *State) Add(key string, value string, sizeLimit uint16) error {
}
checkFrame := st.frameOf(key)
if checkFrame > -1 {
if checkFrame == len(st.execPath) - 1 {
log.Printf("Ignoring load request on frame that has symbol already loaded")
return nil
}
return fmt.Errorf("key %v already defined in frame %v", key, checkFrame)
}
sz := st.checkCapacity(value)

View File

@ -227,6 +227,11 @@ func TestStateLoadDup(t *testing.T) {
if err == nil {
t.Errorf("expected fail on duplicate load")
}
st.Up()
err = st.Add("foo", "xyzzy", 0)
if err != nil {
t.Error(err)
}
}
func TestStateCurrentSize(t *testing.T) {