Cast to int format error (Format function no longer accepts enums)#166
Cast to int format error (Format function no longer accepts enums)#166shewitt-au wants to merge 2 commits intoWerWolv:masterfrom
Conversation
|
I'm a bit disappointed with myself on this one. I wasted too much time trying to solve the problem analytically instead of brute-forcing it. I hope my fix doesn't negate the point of PatternRef. |
|
That does indeed make the pattern refs basically useless. |
|
I had a feeling the fix would defeat the point. |
|
I would appreciate a more elaborate explanation of the need for cloning if you’ve got the time at some point. |
|
I can see why you would endeavor to avoid the "right" solution. |
|
PatternRef was ambitious:) |
|
The issue is basically that the evaluator works with std::shared_ptr to represent objects. Now, when we call |
|
Thanks for the clarification. It’s bed time now, actually well past bed time, but I’m going to contemplate this dilemma. |
|
I've been looking through the code. I'm not sure when you mean when you say, "But the this pointer is of course not a shared_ptr". Is the fundamental problem caused by a cycle of |
|
Here's one such issue: [[nodiscard]] std::string toString() override {
u128 value = this->getValue().toUnsigned();
return Pattern::callUserFormatFunc(PatternRef::create(this), true).value_or(getEnumName(this->getTypeName(), value, m_enumValues));
}The This is what we really want to do: [[nodiscard]] std::string toString() override {
u128 value = this->getValue().toUnsigned();
return Pattern::callUserFormatFunc(this, true).value_or(getEnumName(this->getTypeName(), value, m_enumValues));
}This is how we did it before: [[nodiscard]] std::string toString() override {
u128 value = this->getValue().toUnsigned();
return Pattern::callUserFormatFunc(this->clone(), true).value_or(getEnumName(this->getTypeName(), value, m_enumValues));
} |
|
Yeah, that a bit of a bind alright. What should be simple is made hard by the abstractions that are in place. |
|
No good |
This is a "fix" for this issue (Format function no longer accepts enums). I use quotes because I don't have a deep understanding of how this stuff works. This is the smallest change to PatternRef I've come up with that fixes the issue. Hope it helps.