REBOL3 tracker
  0.9.12 beta
Ticket #0000862 User: anonymous

Project:



rss
TypeBug Statusdismissed Date25-May-2009 12:25
Versionalpha 54 CategoryUnspecified Submitted byLadislav
PlatformAll Severitycrash Priorityhigh

Summary Throw error test crashes
Description the title says it
Example code
b: head insert copy [] try [1 / 0]
pokus1: func [[catch] block [block!] /local elem] [
    for i 1 length? block 1 [
	if error? set/any 'elem first block [
	    throw make error! {Dangerous element}
	]
	block: next block
    ]
]
b: disarm try [pokus1 b]
b/near = [pokus1 b]

Assigned ton/a Fixed inalpha 55 Last Update19-Feb-2014 20:10


Comments
(0000801)
BrianH
25-May-2009 20:51

I left the original code for documentation purposes.

The evaluation of errors has changed in R3, and R2-style error handling doesn't work anymore. The [catch] attribute is no longer supported or necessary, now that we have stack traces. Because of this, you no longer THROW errors. Errors are also not as active, so to trigger them you DO them, or use the value where it isn't accepted, such as assignment without SET/any.

The real error here is that DISARM goes into an endless loop when it tries to disarm the error generated by an uncaught THROW. Here is minimal code to demonstrate the problem: disarm throw 1
(0000807)
Ladislav
26-May-2009 08:37

I checked the simple case and noticed the following additional problem:

>> catch [type? throw 1]
== error!

I expect the expression to yield 1 instead (as in R2).
(0000815)
BrianH
26-May-2009 17:43

That is likely related to bug #771.
(0000832)
Carl
27-May-2009 05:42

Some types of error values are not actually full-objects because for efficiency reasons we don't want to allocate an object in all cases. (These special errors have code numbers less than 100.)
(0000855)
Carl
27-May-2009 20:23

Solution is to make DISARM a no-op mezz function. Done.
(0000856)
Carl
27-May-2009 20:29

Regarding:

>> catch [type? throw 1]

The THROW function returns an error value, which TYPE? converts to a datatype. Can be seen here:

>> type? catch [type? throw 1]
== datatype!

A THROW differs from a DO error! because it does not throw the CPU state, it allows it to unwind which in turn allows all functions along the way to cleanup any state variables.
(0000858)
BrianH
27-May-2009 22:37

I guess that explanation would apply to #771 as well then, Carl?
(0002062)
BrianH
3-Mar-2010 22:25

See #1509 for the catch [type? throw 1] bug.
(0002893)
Ladislav
18-Nov-2010 14:12

In the core-tests suite
(0004246)
BrianH
19-Feb-2014 20:10

There is no DISARM anymore. However, the related bug in #771 and #1509 is fixed.

Date User Field Action Change
19-Feb-2014 20:10 BrianH Comment : 0004246 Added -
19-Feb-2014 20:09 BrianH Status Modified submitted => dismissed
18-Aug-2013 14:13 Ladislav Status Modified tested => submitted
18-Aug-2013 14:13 Ladislav Category Modified => Unspecified
18-Nov-2010 14:12 Ladislav Comment : 0002893 Added -
3-Mar-2010 22:25 BrianH Comment : 0002062 Added -
28-May-2009 08:54 BrianH Status Modified built => tested
27-May-2009 22:37 BrianH Comment : 0000858 Added -
27-May-2009 20:29 carl Comment : 0000856 Added -
27-May-2009 20:24 carl Status Modified reviewed => built
27-May-2009 20:24 carl Fixedin Modified => alpha 55
27-May-2009 20:23 carl Comment : 0000855 Added -
27-May-2009 20:13 carl Comment : 0000832 Modified -
27-May-2009 05:42 carl Comment : 0000832 Added -
26-May-2009 17:43 BrianH Comment : 0000815 Added -
26-May-2009 08:41 Ladislav Comment : 0000807 Modified -
26-May-2009 08:37 Ladislav Comment : 0000807 Added -
25-May-2009 20:51 BrianH Comment : 0000801 Added -
25-May-2009 20:39 BrianH Priority Modified normal => high
25-May-2009 20:39 BrianH Status Modified submitted => reviewed
25-May-2009 20:39 BrianH Version Modified alpha 55 => alpha 54
25-May-2009 20:39 BrianH Code Modified -
25-May-2009 12:25 Ladislav Ticket Added -