Yoav Zibin <yoav.zi...@gmail.com> wrote on 09/02/2010 11:36:07 AM:

> Yes, it's an inference bug.
> Igor recently added the restriction that "this" cannot appear in the
> constraint of the ctor (arguments or return type).

For the record, I have simply re-enabled the checking that was
accidentally disabled earlier.

> And the inference infered this type:
> C:\cygwin\home\Yoav\test\Hello.x10:8-12: This or super cannot be used
> (implicitly or explicitly) in a constructor return type.
>           Type: Counts{self.dim==dimension, self.pos.home==here, *
> self.pos.length==Counts#this.dim*, self.neg.home==here,
> self.neg.length==Counts#this.dim}
> 1 error.
> 
> I already opened a jira on it:
> http://jira.codehaus.org/browse/XTENLANG-1770
> 
> The work around should be to explicitly write the return type (which is 
a
> good habit anyway! I was just talking to Ben about it today. It is a 
good
> habit to always write the return type of methods. Inference of return 
type
> should be disabled in my opinion, since it causes other problems, like 
in
> overriding where the return type must be preserved.)
> But even that still fails.
> 
> So, I removed this check on the return type, until the inference bug is
> fixed.
> 
> Please update to SVN head.

The code is invalid.  The reference to "dim" in the arguments of the
property() statement should not be allowed.  The compiler should have
produced an error for this.

Yan, you should change your constructor to

    public def this (dimension : Int )  {
        property(dimension,
                 ValRail.make[Data](dimension, (i:Int) => 
ValHashMap.make[String,Int](new HashMap[String,Int]())),
                 ValRail.make[Data](dimension, (i:Int) => 
ValHashMap.make[String,Int](new HashMap[String,Int]())));
    }

The above should compile fine even without Yoav's change.  Yoav, please
revert r15989.
        Igor

> 2010/9/2 Yan CRL Li <liyan...@cn.ibm.com>
> 
> >
> > My code piece :
> >
> >   public struct Counts(dim:Int, pos: 
ValRail[ValHashMap[String,Int]](dim),
> > neg:ValRail[ValHashMap[String,Int]](dim)) {
> >        static type Data = ValHashMap[String,Int];
> >        public def this (dimension : Int )  {
> >                property(dimension,
> >                ValRail.make[Data](dim, (i:Int) => ValHashMap.make
> > [String,Int](new HashMap[String,Int]())),
> >                ValRail.make[Data](dim, (i:Int) => ValHashMap.make
> > [String,Int](new HashMap[String,Int]())));
> >        }
> >    }
> > Compile error :
> >  This or super cannot be used (implicitly or explicitly) in a 
constructor
> > return type.
> >
> > This code can be compiled correctly before tag 15544. Current version
> > compiles wrong.
> >
> > Can anyone give me any hint ? Thanks
-- 
Igor Peshansky  (note the spelling change!)
IBM T.J. Watson Research Center
X10: Parallel Productivity and Performance (http://x10-lang.org/)
XJ: No More Pain for XML's Gain (http://www.research.ibm.com/xj/)
"I hear and I forget.  I see and I remember.  I do and I understand" -- 
Confucius


------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to