fix getindex and add debug

This commit is contained in:
2023-06-16 10:02:16 +01:00
parent ec53db45d5
commit 3071da2e2d
5 changed files with 13 additions and 5 deletions

View File

@@ -65,7 +65,7 @@ func parseCall(code UNPARSEcode, index int, codelines []UNPARSEcode) (any, bool,
}
func runCall(c call, stack stack, stacklevel int) (any, ArErr) {
var callable any
var callable any = c.callable
switch x := c.callable.(type) {
case builtinFunc:
callable = x

View File

@@ -28,8 +28,7 @@ func mapGet(r ArMapGet, stack stack, stacklevel int) (any, ArErr) {
}
switch m := resp.(type) {
case ArObject:
if _, ok := m.obj["__getindex__"]; ok {
callable := m.obj["__getindex__"]
if callable, ok := m.obj["__getindex__"]; ok {
resp, err := runCall(call{
callable: callable,
args: r.args,
@@ -48,6 +47,13 @@ func mapGet(r ArMapGet, stack stack, stacklevel int) (any, ArErr) {
}
}
switch m := resp.(type) {
case ArObject:
if obj, ok := m.obj[r.args[0]]; ok {
return obj, ArErr{}
}
}
key, err := runVal(r.args[0], stack, stacklevel+1)
if err.EXISTS {
return nil, err