Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: X10 2.1.2
-
Fix Version/s: X10 2.3.2
-
Component/s: X10 Compiler: Front-end Typechecking
-
Labels:None
-
Number of attachments :
Description
The following code in x10.array.Array does not compile though it should.
public def sequence(){this.rank==1}:Sequence[T] = new Sequence[T]() { public def iterator() = new Iterator[T]() { val regIt = Array.this.iterator(); public def next() = Array.this(regIt.next()); public def hasNext() = regIt.hasNext(); }; public operator this(i:Int)=Array.this(i); public def size()=Array.this.size; };
The problem is that the type-checker is not able to establish that the call Array.this(i) is legal. It is legal because this expression occurs in the scope of the guard this.rank==1. Hence the type-checker should be able to infer that at Array.this(i) is is the case that Array.this.rank==1 and hence the call is legal.
Issue Links
- is depended upon by
-
XTENLANG-2971
Umbrella language/front-end JIRA for X10 2.3.1
-
Hmm.. My analysis above is incorrect, as determined by further investigation.
The root problem is that the type inference for the return type of operator this(i:Int) is being done in the wrong context, one that does not know this.rank==1.
If that line is replaced with:
so that no type inference is needed, it correctly type-checks. The debugger shows the context is carrying the constraint It#this.rank==1.