nitlang / nit

Nit language
http://nitlanguage.org
Apache License 2.0
238 stars 64 forks source link

Fixed quick_sort when array is length 0 or 1 #2811

Closed Louis-Vincent closed 4 years ago

Louis-Vincent commented 4 years ago

Fixed a bug where quick_sort could access out of bound element when to argument smaller or equal to 0.

Before

var xs = [1] default_comparator.quick_sort(xs) # assertion failed

After

var xs = [1] default_comparator.quick_sort(xs) assert xs == [1] # true

Signed-off-by: Louis-Vincent Boudreault lv.boudreault95@gmail.com

Delja commented 4 years ago

Good catch!