In bind() function, if event_name is ivar, it gives COMPILE ERROR.
LadyCailinBot opened this issue ยท 5 comments
CMDHELPER-3138 - Reported by bexco2010
I typed this code on main.ms:
foreach(@event in get_events()) {
try {
bind(@event, null, null, @e,
broadcast(@event'fired -'@e)
)
} catch(Exception @ex) {
broadcast(@ex)
}
}
When I reload codes, CommandHelper gives:
COMPILE ERROR: No event named "" was found.
main:ms:3
Comment by PseudoKnight
There are some instances where arguments can't be dynamic. This is one of them. It's checked on compile time, before @event is ever given a value. I'm not sure if there's a deeper reason for this, but it's intended behavior. It MIGHT be able to be changed so that it only throws a compile error if it's a string, and throws a runtime error if it's an ivar. I'm sure @LadyCailin will chime in here.
Comment by PseudoKnight
Actually there might be a bug anyway. I think it should be hitting this:
if (!children.get(0).isConst()) {
// This ability may be removed in the future, to allow for better compilation checks of event type, once objects are added.
// We'll add this warning to gauge impact.
CHLog.GetLogger().Log(CHLog.Tags.COMPILER, LogLevel.WARNING, "Use of dynamic bind. This may be removed in the future, please"
+ " contact the developers to provide feedback if this affects you.", t);
}
This also gives the deeper reason.
Comment by bexco2010
@PseudoKnight I checked console just now.
It printed on console.