forked from SOM-st/TruffleSOM
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a subtle bug. Since block methods can be defined in different cla…
…sses depending on the count of their arguments we must take this into consideration for guarding dispatch chains depending on blocks
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
da10f5f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smarr I needed to redefine in each block the numArgs method. I could have done it in the Block superclass and reflectively look for the name of the actual class. But then i saw there are other methods like value: which is redefined in every subclass. If the dispatch guard do not consider the different blocks the system misbehaves on sites where two different blocks call that method. So i guess that although subtle and probably not experienced until now, this fix is also valid for TruffleSOM. In the mid-term, I think blocks need a refactoring to avoid this issues. Probably they should also become DynamicObjects, but meanwhile i think this is needed.
da10f5f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand a word.
What can go wrong?
Having blocks with different arity at a single site of a
#value
(etc) send?da10f5f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. At a single site for any message. The guards are not considering the block arity.
da10f5f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it when I see a failing test ;)
da10f5f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the test.
You find the numArgs method already in Block1 and Block2. Actually this was hard to catch because it is just misbehaving (calling the wrong method) but not failing.
The last line of the test is commented because it is capturing a similar issue but for the value selector which is specialized with a primitive. In this case the code just fails because of the wrong number of arguments and i haven't deal with it yet.