ChaiScript
ChaiScript copied to clipboard
ChaiScript handling of transitive inheritance
- Compiler Used: clang 8.0.0
- Operating System: Linux
- Architecture (ARM/x86/32bit/64bit/etc): x86_64
Expected Behavior
Transitive inheritance implied by known inheritance relationships should be automatically respected.
Actual Behavior
Transitive inheritance relationships bust be explicitly added.
Minimal Example to Reproduce Behavior
#include <iostream>
#include <chaiscript/chaiscript.hpp>
class A {};
class B : public A {};
class C : public B {};
int main() {
chaiscript::ChaiScript chai;
chai.add(chaiscript::user_type<A>(), "A");
chai.add(chaiscript::user_type<B>(), "B");
chai.add(chaiscript::user_type<C>(), "C");
chai.add(chaiscript::base_class<A, B>());
chai.add(chaiscript::base_class<B, C>());
// chai.add(chaiscript::base_class<A, C>());
chai.add(chaiscript::fun([] (A) {}), "foo");
chai.add_global(chaiscript::Boxed_Value{C{}}, "value");
try {
chai.eval("foo(value)");
} catch (chaiscript::exception::eval_error &e) {
std::cerr << e.pretty_print();
}
return 0;
}
Error:
Error: "Error calling function 'foo'" With parameters: (C) during evaluation at (__EVAL__ 1, 1)
Expected: (A)
__EVAL__ (1, 1) 'foo value '
The error is fixed by uncommenting the third base_class line; however, this relationship should be presumed based on the previous two.