Method overloading does not work as expected #37

Closed
opened 2018-08-07 22:06:52 +02:00 by belliash · 1 comment
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 2018-08-07 22:06:52 +02:00
Author
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 self-assigned this 2018-08-12 13:03:19 +02:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: aerscript/Aer#37
No description provided.