Mantis - Squeak
Viewing Issue Advanced Details
4867 Compiler minor always 09-10-06 22:44 04-18-10 22:05
lewis  
nicolas cellier  
normal  
closed 3.9  
fixed  
none    
none 3.10.2bc  
0004867: argument of ifNotNil: must be a 0-argument block, code does not match compiler inlining behavior
"Object new ifNotNil: [:object | ]" results in the syntax error "argument of ifNotNil: must be a 0-argument block" when the code appears as if it would allow this.
  
ProtoObject>>ifNotNil: ifNotNilBlock
        "Evaluate the block, unless I'm == nil (q.v.)"
         ^ ifNotNilBlock valueWithPossibleArgs: {self}

The compiler inlines the method, and enforces the zero-argument restriction. The Smalltalk method code has been changed in a way that is inconsistent with this.
This was reported by Zulq Alam on the squeak-dev list, and discussed on the list.
parent of 0006426closed Keith_Hodges ifNotNil: don't accept monadic blocks 
 ProtoObject-ifNotNil.st [^] (266 bytes) 09-11-06 03:15

Notes
(0007052)
wiz   
09-11-06 03:20   
uploaded the previous version from 3.7 for reversion.

'From Squeak3.8alpha of ''17 July 2004'' [latest update: #5976] on 10 September 2006 at 9:13:08 pm'!

!ProtoObject methodsFor: 'testing' stamp: 'md 11/24/1999 19:25'!
ifNotNil: ifNotNilBlock
    "Evaluate the block, unless I'm == nil (q.v.)"

    ^ ifNotNilBlock value! !

historical note: the version in 3.9g has the stamp:

md 1/20/2006 16:19 ProtoObject ifNotNil: {testing}

Yours in service, -- Jerome Peace
(0012936)
lewis   
01-28-09 01:25   
Note: This has been fixed in Pharo.
(0012939)
wiz   
01-30-09 03:16   
Hi Dave,

I am confused by your comment.

Which way did Pharo resolve the problem?
It seemed to me they were leaning towards the allowance of
an argument.

Is there a test to demonstrate the proper behavior. In an ambiguous
situation such as this I think a test would be critical.

Yours in curiosity and service, --Jerome Peace
(0012940)
lewis   
01-30-09 12:20   
It seems to be fixed in Pharo in the sense that the code matches the compiler behavior, which was the subject of this bug report. I can't comment as to what the correct behavior should be (but see discussions on squeak-dev and pharo mailing lists).
(0012941)
wiz   
02-02-09 22:01   
Um.
The discussions on the Pharo list are what confused me.
And not looking at the Pharo code I still don't understand if
the code now forbids an argument
or if the pharo compliler now permits it.
If it was the code that changed then it would be useful to squeak 3.11 if the fileout patch were uploaded here.

Yours in curiosity and service --Jer
(0013316)
nicolas cellier   
09-19-09 21:06   
This is the same bug as 0006426 and has been fixed in the same time.
It is at least fixed in trunk