JakobOvrum/LuaD

Methods name and field name "init" issue

nakajimakotaro opened this issue · 1 comments

My environment is ubuntu14.04 dub

this is not compiled

import luad.all;

class Foo
{
    void init() //this is name init
    {
    }
}
void main()
{
    auto L = new LuaState();
    L.set("Foo", new Foo);
}
import luad.all;

class Foo
{
    int init; //this is name init
}
void main()
{
    auto L = new LuaState();
    L.set("Foo", new Foo);
}

this is compiled

import luad.all;

class Foo
{
    void nit() //this is name nit
    {
    }
}
void main()
{
    auto L = new LuaState();
    L.set("Foo", new Foo);
}
import luad.all;

class Foo
{
    int nit; //this is name nit
}
void main()
{
    auto L = new LuaState();
    L.set("Foo", new Foo);
}

init is a special property in D and should never be used as a member name, whether it's a field or a method. There have been talks in the past to make such members illegal. I don't think it's reasonable to expect introspection code like LuaD's to try to handle it.