fix error message of ⌾(oob⊸⊏)

This commit is contained in:
dzaima 2025-03-12 01:36:54 +02:00
parent 0848faf8c7
commit a6202c8ca6
2 changed files with 12 additions and 4 deletions

View File

@ -946,7 +946,10 @@ B select_ucw(B t, B o, B w, B x) {
B rep;
if (isArr(o) && RNK(x)>0) {
i64 buf[2];
if (wia!=0 && (!getRange_fns[we](tyany_ptr(w), buf, wia) || buf[0]<-(i64)xia || buf[1]>=xia)) thrF("𝔽⌾(a⊸⊏)𝕩: Indexing out-of-bounds (%l∊a, %H≡≢𝕩)", buf[1]>=xia?buf[1]:buf[0], x);
if (wia!=0 && (!getRange_fns[we](tyany_ptr(w), buf, wia) || buf[0]<-(i64)xia || buf[1]>=xia)) {
C2(select, w, x);
fatal("select_ucw expected to error");
}
rep = incG(o);
} else {
rep = c1(o, C2(select, incG(w), incG(x)));

View File

@ -2,6 +2,7 @@
%DEF tvar %USE var _tvar {F _𝕣 x: (CLR@) {F 𝕩 V x}¨ LV 𝕩; w F _𝕣 x: (CLR@) (LV 𝕨) {(𝕨 V w) F 𝕩 V x} LV 𝕩}
%DEF eqvar %USE tvar _eqvar {r 𝕨 𝔽 _tvar 𝕩 !(r)¨ r r}
%DEF evar %USE tvar _evar {ok{} r𝕨 ok𝔽{𝕊: •CurrentError@} _tvar 𝕩 {okr? !"TEST FAIL: variation didn't error"; ("TEST FAIL: varying error messages" ! 1=)r !r}}
%DEF eqerr %USE eqvar _eqerr {ok{} r𝕨 ok𝔽{𝕊: •CurrentError@} 𝕩 {okr? !"TEST FAIL: case didn't error"; ("TEST FAIL: varying error messages" ! 1=)r !r}}
# ¨ & ˘
# !% ⊢⌾(⊢¨) 4 # TODO enable
# !% ⊢⌾(⊢˘) 4 # TODO enable
@ -46,9 +47,13 @@ a←10‿10‿10⥊↕1000 ⋄ ! a ≡ a⌾((↕≢a)⊸⊑) a
n500 an i(-n)+2×n r(2×n)a ! (a) r(i) a
!"𝕨⊏𝕩: 𝕩 cannot be a unit" % 00(00) <0
!"𝕨⊏𝕩: 𝕩 cannot be a unit" % %USE evar (0) {(𝕨)𝕩}_evar <0
!"𝔽⌾(a⊸⊏)𝕩: Indexing out-of-bounds (¯11∊a, ⟨10⟩≡≢𝕩)" % %USE evar 5¯11 {01(𝕨)𝕩}_evar 10101
!"𝔽⌾(a⊸⊏)𝕩: Indexing out-of-bounds (10∊a, ⟨10⟩≡≢𝕩)" % %USE evar 910 {01(𝕨)𝕩}_evar 10101
!"𝔽⌾(a⊸⊏)𝕩: Indexing out-of-bounds (10∊a, ⟨10⟩≡≢𝕩)" % %USE evar "ab" {𝕨(910)𝕩}_evar 10"foo"
!"𝕨⊏𝕩: Indexing out-of-bounds (¯11∊𝕨, 10≡≠𝕩)" % %USE evar 5¯11 {01(𝕨)𝕩}_evar 10101
!"𝕨⊏𝕩: Indexing out-of-bounds (10∊𝕨, 10≡≠𝕩)" % %USE evar 910 {01(𝕨)𝕩}_evar 10101
!"𝕨⊏𝕩: Indexing out-of-bounds (10∊𝕨, 10≡≠𝕩)" % %USE evar "ab" {𝕨(910)𝕩}_evar 10"foo"
!"𝕨⊏𝕩: Indexing out-of-bounds (4.611686018427388e18∊𝕨, 3≡≠𝕩)" % %USE eqerr {𝕩((3262)) "abc"}_eqerr "abc", {𝕊: "abc"}
!"Integer out of range: 9.223372036854776e18" % %USE eqerr {𝕩((3263)) "abc"}_eqerr "abc", {𝕊: "abc"}
!"Expected integer, got 1.1" % %USE eqerr {𝕩((31.1)) 3}_eqerr 3, {1+𝕩}
!"𝕨⊏𝕩: Indexing out-of-bounds (10∊𝕨, 3≡≠𝕩)" % %USE eqerr {𝕩(101112) 3}_eqerr 3, {1+𝕩}
100+(124) <¨10 %% <¨ 0101102310456789
100+(124) <¨10 %% <¨ 0101102310456789
100+(124) 10 %% 0101102310456789