Ignore load request on same level in state
This commit is contained in:
parent
a0f7ad5c80
commit
5a63b24ec1
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user