attempt to concatenate field 'value' (a function value)

[email protected] Sat, 1 Nov 2014 17:45:46 -0000
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Can anybody explain this for me? It used to work on an older system with
lua5.1.

i'm now using lua5.2, luabind version us 0.9.1 (on both systems)

g++ -o lua lua.cpp -lluabind -llua5.2 -ldl -I /usr/include/lua5.2
./lua
lua runtime error
[string "function test(t)..."]:2: attempt to concatenate field 'value' (a
function value)

extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}

#include <luabind/luabind.hpp>
#include <iostream>

struct Test
{
  Test(int v) : value(v) {};
  ~Test() {};
  int value;
};


int DebuggerFunc(lua_State* L)
{
	luabind::object error_msg(luabind::from_stack(L, -1));
	std::cerr << error_msg << std::endl;
	return 0;
}

int main() {
  lua_State *L = luaL_newstate();
  luabind::open(L);

  luabind::module(L)
  [
    luabind::class_<Test>("Test")
    .def(luabind::constructor<int>())
    .def_readonly("value",&Test::value)
  ];

  luaL_dostring(
    L,
    "function test(t)\n"
    "  print(\"value : \" .. t.value)\n"
    "end\n"
  );

  Test t(4);

  try {
    luabind::call_function<int>(L, "test", &t);
  }
  catch (const luabind::error &er)
  {
    std::cerr << er.what() << std::endl;
    lua_State* Ler=er.state();
    DebuggerFunc(Ler);
  }
  catch (...)
  {
    std::cerr << "Unknown error!" << std::endl;
  }
  lua_close(L);
}


------------------------------------------------------------------------------