- callback scheduling issue
- error popup obscures input area
- ui docs
-- vocab popup: sort
+- test factor on linux/ppc
+- auto-generate error-index
+ 0.88:
{ $description "Calls the quotation. If it throws an error, logs the error to the default stream and restores the data stack." } ;
HELP: expired-error.
-{ $values { "obj" "an error" } }
{ $error-description "Thrown by " { $link alien-address } " and " { $link alien-invoke } " if an " { $link alien } " object passed in as a parameter has expired. Alien objects expire if they are saved an image which is subsequently loaded; this prevents a certain class of programming errors, usually attempts to use uninitialized objects, since holding a C address is meaningless between sessions." }
{ $notes "You can check if an alien object has expired by calling " { $link expired? } "." } ;
HELP: io-error.
-{ $values { "error" "an object" } }
{ $error-description "Thrown by the C streams I/O primitives if an I/O error occurs." } ;
HELP: undefined-word-error.
-{ $values { "obj" "an object" } }
{ $error-description "Thrown if an attempt is made to call a word which was defined by " { $link POSTPONE: DEFER: } "." } ;
HELP: type-check-error.
-{ $values { "obj" "an object" } }
{ $error-description "Thrown by various primitives if one of the inputs does not have the expected type. Generic words throw " { $link no-method } " and " { $link no-math-method } " errors in such cases instead." } ;
+HELP: divide-by-zero-error.
+{ $error-description "This error is thrown when " { $link / } " or " { $link /i } " is called with with a zero denominator." }
+{ $see-also "division-by-zero" } ;
+
HELP: signal-error.
-{ $values { "obj" "an object" } }
{ $error-description
"Thrown by the runtime when a Unix signal is received. While signal numbers are system-specific, the following are relatively standard:"
{ $list
} ;
HELP: negative-array-size-error.
-{ $values { "obj" "an object" } }
{ $error-description "Thrown by " { $link <array> } ", " { $link <string> } ", " { $link <vector> } " and " { $link <sbuf> } " if a negative capacity is specified." } ;
HELP: c-string-error.
-{ $values { "obj" "an object" } }
{ $error-description "Thrown by " { $link alien-invoke } " and various primitives if a string containing null bytes, or characters with values higher than 255 is passed in where a C string is expected. See " { $link "c-strings" } "." } ;
HELP: ffi-error.
-{ $values { "obj" "an object" } }
{ $error-description "Thrown by " { $link dlopen } " and " { $link dlsym } " if a problem occurs while loading a native library or looking up a symbol. See " { $link "alien" } "." } ;
HELP: heap-scan-error.
-{ $values { "obj" "an object" } }
{ $error-description "Thrown if " { $link next-object } " is called outside of a " { $link begin-scan } "/" { $link end-scan } " pair." } ;
HELP: undefined-symbol-error.
-{ $values { "obj" "an object" } }
{ $error-description "Thrown if a previously-compiled " { $link alien-invoke } " call refers to a native library symbol which no longer exists." } ;
HELP: user-interrupt.
-{ $values { "obj" "an object" } }
{ $error-description "Thrown by the " { $snippet "t" } " command in the FEP." } ;
HELP: datastack-underflow.
PREDICATE: array kernel-error ( obj -- ? )
dup first \ kernel-error eq? [
- second 0 18 between?
+ second 0 19 between?
] [
drop f
] if ;
{ $outliner [ all-words [ primitive? ] subset ] } ;
ARTICLE: "error-index" "Error index"
-{ $subsection /0 }
{ $subsection alien-callback-error }
{ $subsection alien-invoke-error }
{ $subsection assert }
{ $subsection condition }
{ $subsection datastack-overflow. }
{ $subsection datastack-underflow. }
+{ $subsection divide-by-zero-error. }
{ $subsection empty-queue }
{ $subsection expired-error. }
{ $subsection ffi-error. }
: fraction> ( a b -- a/b )
dup 1 number= [ drop ] [ (fraction>) ] if ; inline
-TUPLE: /0 ;
-: /0 ( -- * ) </0> throw ;
-
M: integer /
dup zero? [
- /0
+ /i
] [
dup 0 < [ [ neg ] 2apply ] when
2dup gcd nip tuck /i >r /i r> fraction>
{ $values { "x" "a bignum" } { "y" "a bignum" } { "z" "a bignum" } }
{ $description "Primitive version of " { $link shift } "." }
{ $warning "This word does not perform type checking, and passing objects of the wrong type can crash the runtime. User code should call the generic word " { $link shift } " instead." } ;
-
-HELP: /0
-{ $error-description "This error is thrown when " { $link / } " is called with two integer inputs, the denominator being zero." }
-{ $notes "Floating point division by zero does not raise an error at all, whereas integer division by zero in " { $link /i } " typically raises an operating system signal (see " { $link signal-error. } ")." } ;
USE: hashtables
USE: io
USE: prettyprint
+USE: errors
[ "hi" V{ 1 2 3 } hash ] unit-test-fails
[ [ \ + = ] ] [ \ + [ = ] curry ] unit-test
! Make sure we report the correct error on stack underflow
-[ { kernel-error 11 f f } ]
+[ { kernel-error 12 f f } ]
[ [ clear drop ] catch ] unit-test
[ -7 <byte-array> ] unit-test-fails
"cont" set
[
"\ + 1 2 3 4"
- <string-reader> <interactive-stream>
+ <string-reader>
parse-interactive "cont" get continue-with
] catch
"0 :res" eval
"Object type: " write dup fourth class .
"Expected type: " write third type>class . ;
+: divide-by-zero-error. ( obj -- )
+ "Division by zero" print drop ;
+
: signal-error. ( obj -- )
"Operating system signal " write third . ;
io-error.
undefined-word-error.
type-check-error.
+ divide-by-zero-error.
signal-error.
negative-array-size-error.
c-string-error.
M: no-math-method summary
drop "No suitable arithmetic method" ;
-M: /0 summary
- drop "Division by zero" ;
-
M: bad-escape summary
drop "Invalid escape code" ;
[ word-name ] swap completions ;
: apropos ( str -- )
- all-words word-completions [ summary ] each ;
+ all-words word-completions [ summary print ] each ;
"Word search" show-titled-popup ;
: show-vocab-words ( workspace vocab -- )
- "" over words <word-search>
+ "" over words natural-sort <word-search>
"Words in " rot append show-titled-popup ;
: show-help-search ( workspace -- )
{
if (BIGNUM_ZERO_P (denominator))
{
- raise(SIGFPE);
+ divide_by_zero_error();
return;
}
if (BIGNUM_ZERO_P (numerator))
{
if (BIGNUM_ZERO_P (denominator))
{
- raise(SIGFPE);
+ divide_by_zero_error();
return (BIGNUM_OUT_OF_BAND);
}
if (BIGNUM_ZERO_P (numerator))
{
if (BIGNUM_ZERO_P (denominator))
{
- raise(SIGFPE);
+ divide_by_zero_error();
return (BIGNUM_OUT_OF_BAND);
}
if (BIGNUM_ZERO_P (numerator))
general_error(ERROR_TYPE,tag_fixnum(type),tagged,true);
}
+void divide_by_zero_error(void)
+{
+ general_error(ERROR_DIVIDE_BY_ZERO,F,F,true);
+}
+
void memory_error(void)
{
- general_error(ERROR_MEMORY,F,F,false);
+ general_error(ERROR_MEMORY,F,F,true);
}
ERROR_IO,
ERROR_UNDEFINED_WORD,
ERROR_TYPE,
+ ERROR_DIVIDE_BY_ZERO,
ERROR_SIGNAL,
ERROR_NEGATIVE_ARRAY_SIZE,
ERROR_C_STRING,
void memory_protection_error(CELL addr, int signal);
void signal_error(int signal);
void type_error(CELL type, CELL tagged);
+void divide_by_zero_error(void);
void memory_error(void);
void primitive_throw(void);
void primitive_die(void);