Starting with the following piece of the field promotion spec:
record Point {
var x: real;
var y: real;
}
var A: [1..5] Point = [i in 1..5] new Point(x=i, y=i);
var X = A.x;
A.y = 1.0;
writeln(X);
writeln(A);
I was checking how the compiler resolves / finds the getter methods for Point while resolving the promoted call A.x (etc.). I observed that the compiler only looks in the current scope (and in the scope of the receiver, the array). This means that if the type is not visible in scope, promotion fails. I suspect this is a bug, because calling .x on a value of type Point -- without bringing the type itself into scope -- works fine. The below example demonstrates this.
module M1 {
record Point {
var x: real;
var y: real;
}
var A: [1..5] Point;
var P: Point;
}
module M2 {
import M1.{A, P};
var myX = P.x; // works fine
var B = A.x; // doesn't compile
proc main() {
writeln(myX);
writeln(B);
}
}
Starting with the following piece of the field promotion spec:
I was checking how the compiler resolves / finds the getter methods for
Pointwhile resolving the promoted callA.x(etc.). I observed that the compiler only looks in the current scope (and in the scope of the receiver, the array). This means that if the type is not visible in scope, promotion fails. I suspect this is a bug, because calling.xon a value of typePoint-- without bringing the type itself into scope -- works fine. The below example demonstrates this.