From 32b37188d37ccaf9e5e1a062003a7f8cc78c8f1a Mon Sep 17 00:00:00 2001 From: dzaima Date: Wed, 28 May 2025 00:56:29 +0300 Subject: [PATCH] fix arr_bptr==NULL path of isSorted isSorted doesn't consume x, but TO_BPTR mutates it --- src/builtins/grade.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/builtins/grade.h b/src/builtins/grade.h index 3d13566f..0bc651e7 100644 --- a/src/builtins/grade.h +++ b/src/builtins/grade.h @@ -389,8 +389,13 @@ bool CAT(isSorted,GRADE_UD(Up,Down))(B x) { #undef HI } case el_B: { - B* xp = TO_BPTR(x); - CMP(compare(xp[i-1], xp[i]) GRADE_UD(>,<) 0) + B* xp = arr_bptr(x); + if (xp!=NULL) { + CMP(compare(xp[i-1], xp[i]) GRADE_UD(>,<) 0) + } else { + SGetU(x) + CMP(compare(GetU(x,i-1), GetU(x,i)) GRADE_UD(>,<) 0) + } } } #undef CASE