#37 Method overloading does not work as expected

Closed
opened 2 years ago by belliash · 1 comments
belliash commented 2 years ago
Owner

AerScript Information

  • Aer Version (or commit ref): bca4d1a2fa
  • Operating System: Linux
  • System Architecture (eg. arm, x86_64, ...): x86_64

Your problem description

Before bca4d1a2fa, PH7 Engine has checked if there are more than one functions/methods with the same name during OP_CALL. If this was true, it executed VmOverload() in order to select proper one. Actually, it does the compution everytime. However when method or function contains some parameters that takes default values, and such parameter are not being overwritten, it fails to match the function properly, what leads to error.

W/o change committed in bca4d1a2fa it is also not working correctly, because any function/method can be called even parameters does not match.

We need to implement some additional checks in VmOverload(). Currently, there is only:

    if((int)SySetUsed(&pLink->aArgs) == nArg) {
        /* Candidate for overloading */
        apSet[i++] = pLink;
    }

which check if number of arguments that method can take equals to the number of arguments really passed. However, function can also take more parameters than really passed, if next one skipped, takes some default value. This check needs to be implemented. Since then, master branch will be broken (unicode_characters.aer fails).

<!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please take a moment to check that your issue doesn't already exist. 3. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> # AerScript Information - Aer Version (or commit ref): bca4d1a2fa - Operating System: Linux - System Architecture (eg. arm, x86_64, ...): x86_64 # Your problem description Before bca4d1a2fa, PH7 Engine has checked if there are more than one functions/methods with the same name during OP_CALL. If this was true, it executed VmOverload() in order to select proper one. Actually, it does the compution everytime. However when method or function contains some parameters that takes default values, and such parameter are not being overwritten, it fails to match the function properly, what leads to error. W/o change committed in bca4d1a2fa it is also not working correctly, because any function/method can be called even parameters does not match. We need to implement some additional checks in VmOverload(). Currently, there is only: if((int)SySetUsed(&pLink->aArgs) == nArg) { /* Candidate for overloading */ apSet[i++] = pLink; } which check if number of arguments that method can take equals to the number of arguments really passed. However, function can also take more parameters than really passed, if next one skipped, takes some default value. This check needs to be implemented. Since then, master branch will be broken (unicode_characters.aer fails).
belliash added the
bug
label 2 years ago
belliash commented 2 years ago
Poster
Owner

I have added a workaround in engine/vm.c in lines 619-620 to fix master branch.
This simply considers a method as candidate if it takes more parameters than really passed. We need to implement there a check mentioned before.

I have added a workaround in engine/vm.c in lines 619-620 to fix master branch. This simply considers a method as candidate if it takes more parameters than really passed. We need to implement there a check mentioned before.
belliash closed this issue 2 years ago
belliash self-assigned this 2 years ago
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.