Skip to content

Commit

Permalink
fix: correct behavior when using method object as variable value acro…
Browse files Browse the repository at this point in the history
…ss different structures

Resolved issues that occurred when assigning a method from one struct as a
variable value in a different struct, ensuring proper method binding and execution.
  • Loading branch information
jacopodl committed Aug 2, 2024
1 parent 9a31aa4 commit 9cea226
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion argon/vm/datatype/arobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,13 @@ ArObject *argon::vm::datatype::AttributeLoadMethod(const ArObject *object, ArObj
if ((aload = AttributeLoad(object, key, false)) == nullptr)
return nullptr;

if (AR_TYPEOF(aload, type_function_) && ((Function *) aload)->IsMethod())
const auto *func = (Function *) aload;
const auto *base = (TypeInfo *) object;

if(AR_GET_TYPE(base) != type_type_)
base = AR_GET_TYPE(base);

if (AR_TYPEOF(func, type_function_) && func->IsMethod() && TraitIsImplemented(base, func->base))
*is_method = true;

return aload;
Expand Down

0 comments on commit 9cea226

Please sign in to comment.