CommandHelper

CommandHelper

46.5k Downloads

@arguments variable overwritten in closures

LadyCailinBot opened this issue ยท 8 comments

commented

CMDHELPER-3059 - Reported by VergilPrime

Closures have a special ivar @arguments, but it's not well documented and overwrites ivars defined in scripts, which causes confusion like below.

Original issue:
@arguments variable not being passed in register_command executor closure

It's supposed to be:
alias
sender
arguments
info

Instead its:
alias
sender
info
empty array

commented

Comment by PseudoKnight

Perhaps we should move the order so that scripts can overwrite @arguments. I think that would be best for this type of situation. At the very least it should be mentioned better in the docs. Either way something should be changed.

commented

Comment by PseudoKnight

Okay, I redefined the issue for tracking purposes.

commented
commented

Comment by LadyCailin

Fixed

commented

Comment by PseudoKnight

Um, since when? I'm on build 2859 and haven't noticed this.

commented

Comment by VergilPrime

I'm on 2867. http://i.imgur.com/qaRoR2T.png

commented

Comment by PseudoKnight

Oh, perhaps it's because you're using the ivar @arguments which is already used in closures. Try @Args and see if it fixes it. We might have to address that in the docs.

Or do you mean that @arguments isn't passing all 4 variables? Give an example.

[edit: didn't see image... looking now]

Okay, it's the former. @arguments is already used and I guess it overwrites your ivar.

commented

Comment by VergilPrime

Yeah I tried @Args and the issues is fixed. Sorry for the confusion. Can you pop in IRC a moment?