Hi, Andreas,

This is a bug in the X10 compiler.  The "return" in the body of the
"at" expression should be interpreted as a return from the enclosing
method, and the code below should produce a parse error (because the
"at" expression doesn't actually compute an expression value).  I've
opened XTENLANG-2823 to track the issue.  Thanks for the report.
        Igor

On Fri, Jun 24, 2011 at 8:04 AM, Andreas Zwinkau <zwin...@kit.edu> wrote:
> What should the following method do?
>
>        static def foo():int {
>                return at (here.next()) {
>                        return 0;
>                };
>        }
>
> According to the language report it is fundamentally correct to put
> "return" into an at expression. However, the report also says
>
>   Limitation: X10 does not currently allow break, continue, or return
>   to exit from an at.
>
> In my opinion, the X10 compiler should output a warning, that this is
> "not yet implemented" or something. The generated C++ code looks as
> intended, though.
>
> Removing the first return, should still be correct code:
>
>        static def foo():int {
>                at (here.next()) {
>                        return 0;
>                };
>        }
>
> However, this results in the following (incorrect) errors.
>
> Test.x10:4: Cannot return value from void method or closure.
> Test.x10:4: Cannot return expression; base type incompatible with method
> return type.
>         Expression: 0
>         Base type: x10.lang.Int
>         Expected base type: void
> Test.x10:5: Unreachable statement.
> 3 errors.

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a 
definitive record of customers, application performance, security 
threats, fraudulent activity and more. Splunk takes this data and makes 
sense of it. Business sense. IT sense. Common sense.. 
http://p.sf.net/sfu/splunk-d2d-c1
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to