jeudi 24 décembre 2015

AS3: Not getting typeError when calling a function

I'm writing my own language from ActionScript as a personal project (yeah, I guess AS3 is not the best language to build a language from, but never mind that).

At any rate, I have a this:

package NodyCode.Classes 
    public class NCString 

        public function rindex(substr:NCString, startIndex:int = 0x7fffffff):uint {
            //code here

I would like an error to be thrown whenever the user uses the wrong type of argument. So I would expect this code to cause an error:

strInstance.rindex('foo', [5]);

Instead, though, rindex is called with startIndex = 5.

Why is [5] converted to 5, and is there any way for me to prevent that? If there isn't, I can always work around this problem, but I'd rather not if I can do otherwise.

Aucun commentaire:

Enregistrer un commentaire