Skip to content

Commit fe13619

Browse files
committed
mark error forwarded from pyx, and don't call eformat for it
1 parent c989b19 commit fe13619

5 files changed

Lines changed: 24 additions & 17 deletions

File tree

jsrc/ct.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ A jtpyxval(J jt,A pyx){ UI4 state;PYXBLOK *blok=(PYXBLOK*)AAV0(pyx);
241241
CLRFUTEXWT; // wait till pending wakealls complete before we allow this block to be deleted
242242
done: // pyx has been filled in. jt->futexwt must be 0
243243
if(likely(blok->pyxvalue!=NULL))R blok->pyxvalue; // valid value, use it
244-
ASSERT(0,blok->errcode); // if error, return the error code
244+
ASSERTPYX(blok->errcode); // if error, return the error code, noting that it was extenally generated
245245
fail:
246246
CLRFUTEXWT;ASSERT(0,err);}
247247

jsrc/d.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,6 @@ R 0;
338338
// this routine also does the work for jtjsigd (domain error with message text), jtjsignal (old-fashioned terse display),
339339
// jtjsignal3 (terse display for lines known to be from an explicit definition, giving line#/column), and
340340
// x 13!:8 y (display text x, set error# y)
341-
// Encoded as follows using upper bits of e:
342-
#define EMSGE 0xff // the error-code part
343-
#define EMSGNOEVM 0x200 // set to suppress moving the terse message
344-
#define EMSGLINEISA 0x400 // line contains A block for message (otherwise it points to string if any and info has the length of the string)
345-
#define EMSGCXINFO 0x800 // info contains line#/col# of error
346-
#define EMSGSPACEAFTEREVM 0x1000 // set if terse message should be followed by a space
347-
#define EMSGLINEISTERSE 0x2000 // set if line has the text for the terse message (13!:8)
348-
#define EMSGLINEISNAME 0x4000 // set if line has the name to use in place of jt->curname
349-
// no bits set means terse display (jsignal)
350-
// bit 9 set: line=failing line, info=failing line#/column for jsignal3
351-
// bit 10 set: line=A text for message (sigstr)
352-
// bit 11 set: line->text as C string (sigd)
353341
//
354342
// we look at emsgstate and do as little as possible if the user isn't going to see the message
355343
//
@@ -375,6 +363,7 @@ A jtjsignale(J jt,I eflg,A line,I info){
375363
jteputlnolf(jt,msg); // header of first line: terse string
376364
A nameblok=jt->curname; nameblok=eflg&EMSGLINEISNAME?line:nameblok; // if user overrides the name, use the user's name
377365
if(nameblok){if(!jt->glock){eputs(": "); ep(AN(nameblok),NAV(nameblok)->s);}} // ...followed by name of running entity
366+
if(eflg&EMSGFROMPYX)eputs(" (from pyx)"); // if the message came from a pyx, mark it as such
378367
eputc(eflg&EMSGSPACEAFTEREVM?' ':CLF); // ... that's the first line, unless user wants added text on the same line
379368
if(!jt->glock){ // suppress detail if locked
380369
if((line!=0) && !(eflg&EMSGLINEISTERSE) && !(jt->emsgstate&EMSGSTATENOLINE)){ // if there is a user line, and its display not suppressed
@@ -397,6 +386,8 @@ A jtjsignale(J jt,I eflg,A line,I info){
397386
jt->etxn1=jt->etxn; // save length of finished message
398387
}
399388
}
389+
// if this error was forwarded from a pyx, we can't eformat it - we have no self/arguments. Set that we have tried formatting already to suppress further formatting
390+
if(eflg&EMSGFROMPYX)jt->emsgstate|=EMSGSTATEFORMATTED;
400391
// obsolete jt->curname=0; // clear the name always
401392
R 0;
402393
}

jsrc/j.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,20 @@ struct jtimespec jmtfclk(void); //'fast clock'; maybe less inaccurate; intended
709709
#define NTSTACK (1LL<<(AUDITEXECRESULTS?24:14)) // number of BYTES in an allocated block of tstack - pointers to allocated blocks - allocation is bigger to leave this many bytes on boundary
710710
#define NTSTACKBLOCK 2048 // boundary for beginning of stack block
711711

712+
// flags for jteformat
713+
#define EMSGE 0xff // the error-code part
714+
#define EMSGNOEVM 0x200 // set to suppress moving the terse message
715+
#define EMSGLINEISA 0x400 // line contains A block for message (otherwise it points to string if any and info has the length of the string)
716+
#define EMSGCXINFO 0x800 // info contains line#/col# of error
717+
#define EMSGSPACEAFTEREVM 0x1000 // set if terse message should be followed by a space
718+
#define EMSGLINEISTERSE 0x2000 // set if line has the text for the terse message (13!:8)
719+
#define EMSGLINEISNAME 0x4000 // set if line has the name to use in place of jt->curname
720+
#define EMSGFROMPYX 0x8000 // set if this error is being copied from a pyx (it can't be analyzed, and it should be marked specially
721+
// no bits set means terse display (jsignal)
722+
// bit 9 set: line=failing line, info=failing line#/column for jsignal3
723+
// bit 10 set: line=A text for message (sigstr)
724+
// bit 11 set: line->text as C string (sigd)
725+
712726
#ifndef PYXES
713727
#define PYXES 1
714728
#endif
@@ -819,8 +833,9 @@ struct jtimespec jmtfclk(void); //'fast clock'; maybe less inaccurate; intended
819833
// #define ASSERT(b,e) {if(unlikely(!(b))){fprintf(stderr,"error code: %i : file %s line %d\n",(int)(e),__FILE__,__LINE__); jsignal(e); R 0;}}
820834
#define ASSERTD(b,s) {if(unlikely(!(b))){jsigd((s)); R 0;}}
821835
#define ASSERTMTV(w) {ARGCHK1(w); ASSERT(1==AR(w),EVRANK); ASSERT(!AN(w),EVLENGTH);}
822-
#define ASSERTN(b,e,nm) {if(unlikely(!(b))){jtjsignale(jt,e|0x4000,(nm),0); R 0;}} // signal error, overriding the running name with a different one
823-
#define ASSERTNGOTO(b,e,nm,lbl) {if(unlikely(!(b))){jtjsignale(jt,e|0x4000,(nm),0); goto lbl;}} // same, but without the exit
836+
#define ASSERTN(b,e,nm) {if(unlikely(!(b))){jtjsignale(jt,e|EMSGLINEISNAME,(nm),0); R 0;}} // signal error, overriding the running name with a different one
837+
#define ASSERTNGOTO(b,e,nm,lbl) {if(unlikely(!(b))){jtjsignale(jt,e|EMSGLINEISNAME,(nm),0); goto lbl;}} // same, but without the exit
838+
#define ASSERTPYX(e) {jsignal((e)|EMSGFROMPYX); R 0;}
824839
#define ASSERTSYS(b,s) {if(unlikely(!(b))){fprintf(stderr,"system error: %s : file %s line %d\n",s,__FILE__,__LINE__); jsignal(EVSYSTEM); jtwri(JJTOJ(jt),MTYOSYS,"",(I)strlen(s),s); R 0;}}
825840
#define ASSERTSYSV(b,s) {if(unlikely(!(b))){fprintf(stderr,"system error: %s : file %s line %d\n",s,__FILE__,__LINE__); jsignal(EVSYSTEM); jtwri(JJTOJ(jt),MTYOSYS,"",(I)strlen(s),s);}}
826841
#define ASSERTW(b,e) {if(unlikely(!(b))){if((e)<=NEVM)jsignal(e); else jt->jerr=(e); R;}}

jsrc/v0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static F1(jtrfc){A r,w1;I m=0,n,t;
226226
n=AN(w); t=AT(w); // n=#coeffs, t=type
227227
if(n){
228228
ASSERT(ISDENSETYPE(t,NUMERIC),EVDOMAIN); // coeffs must be dense numeric
229-
RZ(r=jico2(ne(w,num(0)),num(1))); m=AV(r)[0]; m=(m==n)?0:m; // r=block for index of last nonzero; m=degree of polynomial (but 0 if all zeros)
229+
RZ(r=jico2(ne(w,num(0)),num(1))); RZ(r=mkwris(r)) m=AV(r)[0]; m=(m==n)?0:m; // r=block for index of last nonzero; m=degree of polynomial (but 0 if all zeros)
230230
ASSERT(m||equ(num(0),head(w)),EVDOMAIN); // error if unsolvable constant polynomial
231231
}
232232
// switch based on degree of polynomial

test/gtdot.ijs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ wthr N
237237
amv =. 16 T. 0 NB. AMV with value 0
238238
(>: i. 3000) -: /:~ ; amv f t. ''"0 ] 3 $ 1000
239239

240-
240+
'|ill-formed name (from pyx)' -: LF taketo (>@[ 9!:59@0) :: ((13!:12)@(0$0) ) 13!:8 t. 'worker' 4 NB. pyx error is so flagged
241+
'|ill-formed name (from pyx)' -: LF taketo (>@[ 9!:59@0) :: ((13!:12)@(0$0) ) 13!:8 t. '' 4 NB. pyx error is so flagged
241242

242243
'domain error' -: ". etx '0 t. ($0)'
243244
'domain error' -: ". etx '+ t. 1.5'

0 commit comments

Comments
 (0)