Enforcing return value types

Nathan de Vries nathan at atnan.com
Mon Nov 12 23:38:31 PST 2007

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 {
            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 


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 :).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2139 bytes
Desc: not available
Url : http://mail.mozilla.org/pipermail/es-discuss/attachments/20071113/c71cee7e/attachment-0002.bin 

More information about the Es4-discuss mailing list