Merged
Conversation
Bjvanminnen
approved these changes
Nov 8, 2017
Bjvanminnen
left a comment
There was a problem hiding this comment.
LGTM. I know Paul did a bunch of work on testing the interpreter. It would be good to (a) see if this changes the pass/fail state of any tests and (b) perhaps add a test for it if not.
Author
|
I'm working on a regression unit test for this in the |
|
why bubble sort |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Turns out the
Array.prototype.sortpolyfill, implemented as a bubble sort, is broken.Brought to our attention by a Zendesk ticket and easily reproduced in App Lab with the following code:
The problem is that this
Array.prototype.sortpolyfill, which uses a bubble sort, is implemented incorrectly:JS-Interpreter/interpreter.js
Lines 1100 to 1117 in 37933e4
The exact issue is the
if (changes <= 1) break;line. Stepping through the algorithm for the broken case, we can see that we're breaking too early, when only one swap has occurred in the pass but there's still more work to do.The solution is to check
changes < 1or just!changes. That's what's happened upstream in addition to some other optimizations we should eventually grab, but for now I want a very targeted bugfix.