Sign in to follow this  
Sir Ementaler

Error for non-default namespace interfaces used in methods of mixin classes inherited from by classes in another namespaces

Recommended Posts

I just couldn't help but make the title comprehensive.

Here's an example piece of code that, tested in AngelScript 2.29.2, causes a compilation error that shouldn't happen:

namespace n {
	interface i {}
	mixin class m {
		void f(i@) {}
	}
}
class c : n::m {}

The error reads:

ERR : Identifier 'i' is not a data type in global namespace

...which is irrefutably true, but hardly justifying. Handles to the interface can be used correctly as members of the mixin class but an attempt to use them as method arguments or other local variables in methods will make the compiler try to use types defined in the global namespace (or whatever the namespace of the class named "c" in the example is). It goes without saying that this may have bad consequences if, for example, both the local and global namespaces contain an interface named "i" and the mixin class is registered as:

mixin class m {
	i@ foo;
	void f(i@ bar) {
		@foo = @bar;
	}
}

Such code will generate a rather hilarious error:

ERR : Can't implicitly convert from 'i@&' to 'i@'.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this