delve icon indicating copy to clipboard operation
delve copied to clipboard

eval: support arbitrary map types?

Open firelizzard18 opened this issue 4 months ago • 2 comments

Adding something like this:

if mtyp, ok := expr.(*ast.MapType); ok {
	keyTyp, err := bi.findTypeExpr(mtyp.Key)
	if err != nil {
		return nil, err
	}
	elemTyp, err := bi.findTypeExpr(mtyp.Value)
	if err != nil {
		return nil, err
	}

	typ := new(godwarf.MapType)
	typ.KeyType = keyTyp
	typ.ElemType = elemTyp
	typ.Name = fmt.Sprintf("map[%v]%v", keyTyp, elemTyp)
	typ.Type = typ
	return typ, nil
}

to (*BinaryInfo).findTypeExpr would allow evaluating arbitrary map types. I can't think of a scenario where this would matter, but it also seems a bit odd that evaluating a map[Key]Value expression will fail if that specific type does not exist in the DWARF section.

firelizzard18 avatar Apr 02 '24 02:04 firelizzard18