Mantis - Squeak
Viewing Issue Advanced Details
5793 ST80 minor always 01-20-07 05:57 05-12-14 19:46
gilad  
nicolas cellier  
normal  
resolved 3.8  
fixed  
none    
none trunk  
0005793: Empty blocks do not conform to Blue Book
An empty block is defined to return nil. In Squeak, it returns its last argument. This makes very little sense, and is different from other Smalltalks. I suppose you dare not change it, as who knows what code relies on this behavior. To confirm this, define the following method in any class

emptyBlock
^[:x :y :z | ] value:1 value: 2 value: 3

Then create an instance and invoke it. It evaluates to 3 instead of nil.
 EmptyBlockResult-M5793-Test.1.cs [^] (727 bytes) 09-27-07 20:46
 EmptyBlockResult-M5793-PatchForOldCompiler.1.cs [^] (1,715 bytes) 09-27-07 20:46
 EmptyBlockResult-M5793-Test.2.cs [^] (827 bytes) 04-03-08 20:37
 EmptyBlockResult-M5793-PatchForOldCompiler.2.cs [^] (1,727 bytes) 04-03-08 20:37

Notes
(0011216)
nicolas cellier   
09-27-07 20:51   
Just to exercize, a patch for the old compiler.
Note that the NewCompiler already answer nil.
(0011968)
nicolas cellier   
04-03-08 20:38   
Ah Ah, stupid, just forgot to test if statements were empty...

A test.2.cs and patch.2.cs do it a little better.
(0014496)
nicolas cellier   
05-12-14 19:46   
Fixed in 4.6 trunk by Eliot's
http://source.squeak.org/trunk/Compiler-eem.280.mcz [^]
Some details in https://code.google.com/p/pharo/issues/detail?id=1614 [^]