Euphoria Ticket #890: functions passed to delete_routine exits the program

This code exits unexpectedly.

include std/os.e 
 
enum KEYBOARD = 0, SCREEN 
 
function bad_cleanup_routine(object x) 
    puts(SCREEN, "cleanup\n") 
	return 0 
end function 
 
function new_object_with_cleanup() 
	return delete_routine(1, routine_id("bad_cleanup_routine")) 
end function 
 
integer x = new_object_with_cleanup() 
x = 4 
 
while x do 
    puts(SCREEN, "It's working.\n") 
    x = x - 1 
    sleep(1) 
end while 

We expect to see

It's working 
It's working 
It's working 
It's working 

but we get instead:


 

nothing!

The user shouldn't pass a function as a cleanup routine. It should be a procedure. Garbage in garbage out but this is EUPHORIA. It would be good if we could catch this error and display ex.err instead of exiting the program.

I argue this is a bug but others might see it differently.

Details

Type: Bug Report Severity: Normal Category: Language
Assigned To: unknown Status: New Reported Release: 4.0.5
Fixed in SVN #: View VCS: none Milestone:

1. Comment by mattlewis Feb 13, 2014

I agree. We should check to make sure we get a good routine id.

Search



Quick Links

User menu

Not signed in.

Misc Menu