Pharo SubscriptOutOfBounds:5 error

坚强是说给别人听的谎言 提交于 2020-01-16 16:29:07

问题


I have a Pharo extension that adds promises to Pharo Smalltalk. I then use the promise extension to do a bank transfer with the following bank application.An account contacts the bank in order to transfer money to another account. This code fails with the error SubscriptOutOfBounds:5. I looked at Recursive method in pharo produces #SubscriptOutOfBounds:8. It talks about array bounds but I have no clue where I could be using arrays in my implementation unless the stack does.The debugger says something about arrays but at the moment it is too cryptic for me.The promises work just fine with other examples but fail for this particular example. And it appears the error occurs due to the commented out code in Account>>transfer:to:

Below is Account>>transfer:to:

transfer: amount to: account
        | bank promise|
        bank := Bank new.
        (availability > (lowerLimit + amount)) ifTrue: [    availability := availability - amount.
        promise := [ bank transfer: amount from: self to: account ]promiseValue. 
        "promise
            then: [ :respose | 
                respose
                    ifTrue: [ self reduceBalance: amount ] ]
            catch: [ :error | ^error ] "]
            ifFalse: [ ^ self ].

And this is Bank >> transfer:amount:from: to:

transfer: amount from: anAccount1 to: anAccount2
    |transfered|
    transfered := false.
    (anAccount1 availableBalance < anAccount1 lowerLimit + amount)
     ifTrue: 
    [self error: 'Account lower Limit reached', (anAccount1 lowerLimit) printString ] 
    ifFalse:
    [ self deposit: amount to: anAccount2. transfered := true ].
    ^transfered 

What could be the cause of this error?

来源:https://stackoverflow.com/questions/50086700/pharo-subscriptoutofbounds5-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!