Wrong error message from BlockClosure ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Wrong error message from BlockClosure ?

Karl Ramberg
#(1 2) do:[:a :b| b] "do it"

Error: 'This block accepts 2 argument, but was called with 1 arguments.'

Should not the numArgs and the numArgsForInvocation switch place here ?

BlockClosure>>numArgsError: numArgsForInvocation

| printNArgs |
printNArgs := [:n| n printString, ' argument', (n = 1 ifTrue: [''] ifFalse:['s'])]. 
self error: 
'This block accepts ', (printNArgs value: numArgs), 
', but was called with ', (printNArgs value: numArgsForInvocation), '.'


Reply | Threaded
Open this post in threaded view
|

Re: Wrong error message from BlockClosure ?

Eliot Miranda-2
Shurley shome mishtake, hic!  The block clearly has 2 arguments and is called with one, and the print block prints "N arguments" for anything other than 1, so how does the error message come out as you report??

Eliot (phone)

On Apr 30, 2015, at 3:25 AM, karl ramberg <[hidden email]> wrote:

> #(1 2) do:[:a :b| b] "do it"
>
> Error: 'This block accepts 2 argument, but was called with 1 arguments.'
>
> Should not the numArgs and the numArgsForInvocation switch place here ?
>
> BlockClosure>>numArgsError: numArgsForInvocation
>
> | printNArgs |
> printNArgs := [:n| n printString, ' argument', (n = 1 ifTrue: [''] ifFalse:['s'])].
> self error:
> 'This block accepts ', (printNArgs value: numArgs),
> ', but was called with ', (printNArgs value: numArgsForInvocation), '.'
>

Reply | Threaded
Open this post in threaded view
|

Re: Wrong error message from BlockClosure ?

Karl Ramberg
Hm, 
I think you can forget this mail.
This was yet another PEBCAK.

Karl

On Thu, Apr 30, 2015 at 2:02 PM, Eliot Miranda <[hidden email]> wrote:
Shurley shome mishtake, hic!  The block clearly has 2 arguments and is called with one, and the print block prints "N arguments" for anything other than 1, so how does the error message come out as you report??

Eliot (phone)

On Apr 30, 2015, at 3:25 AM, karl ramberg <[hidden email]> wrote:

> #(1 2) do:[:a :b| b] "do it"
>
> Error: 'This block accepts 2 argument, but was called with 1 arguments.'
>
> Should not the numArgs and the numArgsForInvocation switch place here ?
>
> BlockClosure>>numArgsError: numArgsForInvocation
>
>       | printNArgs |
>       printNArgs := [:n| n printString, ' argument', (n = 1 ifTrue: [''] ifFalse:['s'])].
>       self error:
>                       'This block accepts ', (printNArgs value: numArgs),
>                       ', but was called with ', (printNArgs value: numArgsForInvocation), '.'
>




Reply | Threaded
Open this post in threaded view
|

Re: Wrong error message from BlockClosure ?

Levente Uzonyi-2
In reply to this post by Karl Ramberg
Try #groupsDo: :)

Levente

On Thu, 30 Apr 2015, karl ramberg wrote:

> #(1 2) do:[:a :b| b] "do it"
>
> Error: 'This block accepts 2 argument, but was called with 1 arguments.'
>
> Should not the numArgs and the numArgsForInvocation switch place here ?
>
> BlockClosure>>numArgsError: numArgsForInvocation
>
> | printNArgs |
> printNArgs := [:n| n printString, ' argument', (n = 1 ifTrue: [''] ifFalse:['s'])]. 
> self error: 
> 'This block accepts ', (printNArgs value: numArgs), 
> ', but was called with ', (printNArgs value: numArgsForInvocation), '.'
>
>