CommandHelper

CommandHelper

46.5k Downloads

In bind() function, if event_name is ivar, it gives COMPILE ERROR.

LadyCailinBot opened this issue ยท 5 comments

commented

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
commented

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.

commented

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.

commented

Comment by PseudoKnight

Did you truncate that out of your log?

commented

Comment by bexco2010

@PseudoKnight I checked console just now.
It printed on console.

commented

Comment by PseudoKnight

Okay, so not a functional bug so much as an out-dated message.