Skip to content

assertion failure in object_rep::add_dependency #22

Description

@nitrocaster

Although this is not specifically related to deboostifying, I considered it would be reasonable to open an issue here since it is the most active fork at the moment.

The problem was described here:

The minimal working example is provided by the author of the above topic:

I basically copy-pasted it here:

extern "C" {
#include <lualib.h>
};
#include <luabind/luabind.hpp>
#include <stdio.h>

using namespace luabind;

class Widget
{
public:
    Widget(const char* msg = "no msg", Widget* parent = nullptr) :
        msg(msg), parent(parent)
    {}
    virtual void foo() { puts("Widget::foo()"); }

    std::string msg;
    Widget* parent;
};

class WidgetWrap : public Widget, public luabind::wrap_base
{
public:
    WidgetWrap(const char* msg, Widget* parent) :
        Widget(msg, parent)
    {}
    void foo() override { call<void>("foo"); }
    static void default_foo(Widget* base) { base->Widget::foo(); }
};

int main()
{
    lua_State* L = luaL_newstate();
    luaL_openlibs(L);
    luabind::open(L);
    module(L)
    [
        class_<Widget, no_bases, default_holder, WidgetWrap>("Widget")
            .def(constructor<const char*, Widget*>())
            .def_readonly("parent", &Widget::parent)
            .def("foo", &Widget::foo, &WidgetWrap::default_foo)
    ];
    const char* code =
        "class 'MyWidget' (Widget)\n"
        "function MyWidget:__init(msg, parent)\n"
        "  Widget.__init(self, msg, parent)\n"
        "  if parent ~= nil then\n"
        "    self.parent.num = 0\n"
        "  end\n"
        "end\n"
        "function MyWidget:foo()\n"
        "  self.parent.num = self.parent.num + 1\n"
        "end\n"
        "parent = MyWidget('parent')\n"
        "child = MyWidget('child', parent)\n";
    luaL_dostring(L, code);
    auto child = object_cast<Widget*>(globals(L)["child"]);
    for (int i = 0; i < 48; i++)
        child->foo();
    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions