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

Retrieving optional member value fails if None is assigned in linear history #118

Closed
heinezen opened this issue Sep 15, 2024 · 0 comments · Fixed by #119
Closed

Retrieving optional member value fails if None is assigned in linear history #118

heinezen opened this issue Sep 15, 2024 · 0 comments · Fixed by #119
Labels
bug does not work as we'd expect it c++ involves C++ code

Comments

@heinezen
Copy link
Member

When the value of an optional nyan member is retrieved but the value is None, the retrieval currently fails with the error

Traceback (most recent call last):
 -> ? [0x555555569845]
 -> __libc_start_main+0x8b [0x7ffff742a28b]
 -> ? [0x7ffff742a1ca]
 -> ? [0x55555556ca68]
 -> ? [0x55555556bfa6]
 -> ? [0x555555569f94]
 -> std::optional<std::shared_ptr<nyan::Object> > nyan::Object::get_optional<nyan::Object, true>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long) const+0x44 [0x7ffff7e7d144]
 -> std::optional<std::shared_ptr<nyan::ObjectValue> > nyan::Object::get_optional<nyan::ObjectValue, true>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long) const+0x5e [0x7ffff7e7f6c2]
 -> nyan::Object::get_value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long) const+0x43 [0x7ffff7e7ca79]
 -> nyan::Object::calculate_value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long) const+0x2cf [0x7ffff7e7d52b]
 -> nyan::Value::apply(nyan::Member const&)+0x51 [0x7ffff7ed920d]
 -> nyan::None::apply_value(nyan::Value const&, nyan::nyan_op)+0x69 [0x7ffff7ebcd03]
 -> nyan::InternalError::InternalError(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x2e [0x7ffff7e6148c]
 -> nyan::Error::Error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool)+0xed [0x7ffff7e60a83]
 -> nyan::Backtrace::analyze()+0x64 [0x7ffff7e60508]
nyan::InternalError:
None can't get an applied value - assign Value directly to member instead

Note that this only happens when None is assigned in a parent member.

How to reproduce

nyan data:

First():
    member : optional(int) = None

Second(First):
    pass

Code:

Object second = db.get_object("Second");
std::optional<int> member_val = second.get_optional<int, true>("member");

Expected Result

optional member values can be retrieved without crashes.

@heinezen heinezen added bug does not work as we'd expect it c++ involves C++ code labels Sep 15, 2024
@heinezen heinezen linked a pull request Sep 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug does not work as we'd expect it c++ involves C++ code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant