I'm guessing you're just experiencing the effects of
http://bugs.ecmascript.org/ticket/285. The correct behavior is a
run-time error in standard mode; compile-time error in strict mode.
--lars
On Nov 12, 2007 11:38 PM, Nathan de Vries <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> What's the expected behaviour for a function returning a value, of which
> the type is contrary to the type defined in the function declaration?
>
> For example:
>
> var func:Function = function():int {
> return "This is not an int";
> }
> typeof(func()); // string
>
> Is this expected behaviour? Here's some similar Actionscript 3 code:
>
> package {
> class ReturnTest {
> public function ReturnTest():void {
> returnInt();
> }
> private function returnInt():int {
> return "String instead";
> }
> }
> }
>
> ...which produces the following compile-time error:
>
> Implicit coercion of a value of type String to an unrelated type
> int.
>
>
> Regards,
>
> --
> Nathan de Vries
>
> PS: Fantastic work with the Linux build of the reference implementation.
> I'm working my way through the overview documentation, and will probably
> have a poke at the SML when I'm feeling more game :).
>
> _______________________________________________
> Es4-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es4-discuss
>
>
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss