Skip to content

Fix non userdata const reference overloads - #270

Merged
kunitoki merged 1 commit into
masterfrom
dev/fix_non_userdata_stack
Sep 8, 2026
Merged

kunitoki merged 1 commit into
masterfrom
dev/fix_non_userdata_stack

Conversation

@kunitoki

@kunitoki kunitoki commented Sep 8, 2026

Copy link
Copy Markdown
Owner

This pull request fixes a compile-time error in LuaBridge that occurred when using references or pointers to non-userdata types (like int, double, or std::string) with luabridge::overload<const T&>(...). The main change is making the isInstance method in several StackOpSelector specializations a template, allowing correct instantiation and use with various types. New tests have been added to ensure these cases work as expected.

Core Fixes to Type Handling:

  • Made isInstance a template method in all relevant StackOpSelector specializations for pointers and references to non-userdata types in both Distribution/LuaBridge/LuaBridge.h and Source/LuaBridge/detail/Stack.h, allowing proper compilation and usage with types like int, double, and std::string. [1] [2] [3] [4] [5] [6] [7] [8]

Testing Improvements:

  • Added ReferenceAndPointerToNonUserdataTypes test in StackTests.cpp to verify that isInstance works for references and pointers to non-userdata types, and that explicit template arguments are handled correctly.
  • Added tests in OverloadTests.cpp to ensure overloads with const reference parameters for non-userdata types and strings work without ambiguity or compile errors.

@kunitoki
kunitoki merged commit 29ff247 into master Sep 8, 2026
45 checks passed
@kunitoki
kunitoki deleted the dev/fix_non_userdata_stack branch September 8, 2026 20:42
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

Successfully merging this pull request may close these issues.

1 participant