code: func (m *Message) ToProto() (proto.Message, error) {
  	ptr := m.typ.NewProtoMessage() // ~ ptr := &ProtoMessage{}
  	msg := ptr.Elem()              // ~ msg := *ptr (a reference)
  
  	for name, val := range m.fields {
  		fd, ok := m.typ.fields[name]
  		if !ok {
  			panic("should not happen, SetField and Attr checks the structure already")
  		}
  		if err := assign(fd.onProtoReflection(msg, reflectToProto), val); err != nil {
  			return nil, fmt.Errorf("bad value for field %q of %q - %s", name, m.Type(), err)
  		}
  	}
  
  	return ptr.Interface().(proto.Message), nil
  }
docs: // ToProto returns a new populated proto message of an appropriate type.
  //
  // Returns an error if the data inside the Starlark representation of
  // the message has a wrong type.