Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Templated & aliased classes are not indexed #1665

Open
trexxet opened this issue Jan 25, 2025 · 0 comments
Open

Bug: Templated & aliased classes are not indexed #1665

trexxet opened this issue Jan 25, 2025 · 0 comments

Comments

@trexxet
Copy link

trexxet commented Jan 25, 2025

Class:

template<typename T>
struct Test { T x; };
template <typename T>
using OtherTest = Test<T>;

Binding:

	auto bindTest = [this] <template <typename> class C1, typename C2> (const std::string& name) {
		this->state.new_usertype<C1<C2>> (name, "x", &C1<C2>::x);
	};
	bindTest.operator()<Test, int> ("Test");
	bindTest.operator()<OtherTest, int> ("OtherTest");
	bindTest.operator()<Test, float> ("Testf");
	bindTest.operator()<OtherTest, float> ("OtherTestf");

Script:

test1 = Test.new()
test1.x = 10

Error:

attempt to index a sol.Lua::Test<int> value (global 'test1')

Note that if I remove either of T = float uses

	bindTest.operator()<Test, float> ("Testf");
	bindTest.operator()<OtherTest, float> ("OtherTestf");

or alias bindings

	bindTest.operator()<OtherTest, int> ("OtherTest");
	bindTest.operator()<OtherTest, float> ("OtherTestf");

then the script works fine.

Lua 5.4.7, Sol 3.2.3

@trexxet trexxet changed the title Binded templated class is not indexed Alias class is not indexed Jan 25, 2025
@trexxet trexxet changed the title Alias class is not indexed Binded templated class is not indexed Jan 25, 2025
@trexxet trexxet changed the title Binded templated class is not indexed Binded, templated & aliased class is not indexed Jan 25, 2025
@trexxet trexxet changed the title Binded, templated & aliased class is not indexed Bug: Templated & aliased classes are not indexed Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant