Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Method chain calls causes Interpreter to trigger the methods multiple times #9

Closed
lvcabral opened this issue Sep 13, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@lvcabral
Copy link
Collaborator

lvcabral commented Sep 13, 2023

In the line below, the method TotalSeconds is called 4 times (to check add a console.log in the implementations):
? CreateObject("roTimeSpan").TotalSeconds().ToStr().Trim()

User @strattonbrazil also reported:

This is also happening for similar chained calls such as:

" 3 ".trim().toInt()

where trim() is called twice. I also found this has always behaved this way and went unnoticed since most of the chained functions had little to no side effects and only their values were used in testing. I also confirmed that this seems specific to function chaining and other cases like 1 + 2 + 3 have the appropriate number of addition operations.

Using the example above, it appears the trim() call is evaluated once in Interpreter.visitDottedGet() and evaluated in Interpreter.visitCall(). While this has some performance concerns, this can certainly introduce more problems when more functions with side effects are introduced. I'll start looking at some options. I'm guessing the Interpreter.visitCall() is the appropriate place to do this evaluation and Interpreter.visitDottedGet() needs to be updated.

@lvcabral lvcabral added the bug Something isn't working label Sep 13, 2023
@lvcabral
Copy link
Collaborator Author

image

@lvcabral
Copy link
Collaborator Author

Addressed by #22

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant