Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Critical
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: X10 2.3.2
-
Component/s: X10 Compiler: Front-end Typechecking
-
Labels:None
-
Number of attachments :
Description
I explicitly made L an ArrayList[Rail[Int]]. So why, when I take an element out of it, don't I get a Rail[Int]? And it's not even a problem with Rail being typedefs or something – I get the same thing when I explicitly say the constraint.
import x10.util.*; public class ListRail { public static def main(argv:Array[String](1)) { val L = new ArrayList[Rail[Int]](); L.add(new Rail[Int](30, 0)); val r : Rail[Int] = L(0); val N = new ArrayList[Array[Int]{self.rank==1}](); N.add(new Array[Int](30, 0)); val s : Array[Int]{self.rank==1} = N(0); } }
Here are the error messages:
/Users/bard/x10/tmp/listraii/ListRail.x10:6: Cannot assign expression to target; constraints not satisfied.
Expression: L.operator()(0)
Type: x10.array.Array[x10.lang.Int]{L!=null}
Unsatisfied constraints: {self.rank==1, self.zeroBased==true, self.rect==true, self.rail==true}
/Users/bard/x10/tmp/listraii/ListRail.x10:10: Cannot assign expression to target; constraints not satisfied.
Expression: N.operator()(0)
Type: x10.array.Array[x10.lang.Int]{N!=null}
Unsatisfied constraints: {self.rank==1}
2 errors.
Issue Links
- duplicates
-
XTENLANG-2875
Type constraint not propagated to return type of DistArray.restriction(Place)
-
- is depended upon by
-
XTENLANG-2971
Umbrella language/front-end JIRA for X10 2.3.1
-
Interestingly enough, the code fragment below does typecheck:
val L = new ArrayList[Rail[Int]](); L.add(new Rail[Int](30, 0)); val r : Rail[Int] = L.get(0);Looking at ArrayList
public operator this(i: int) = a(i); public def get(i: int): T = a(i);Note that the operator definition is allowing the return type to be inferred from the type of a
, which the get method specifies it explicitly. Operator this(int) on GrowableIndexedMemoryChunk[T](the type of 'a') has an explicit return type of T. So, this certainly looks like a tyepchecker bug, perhaps a bad interaction between constrained types and return type inference.