Description
The following code should compile, but fails to do so
use Python;
var interp = new Interpreter();
var lst = interp.get('list')(1, 2, 3);
var arr: owned PyArray()?;
for i in lst {
writeln(i);
}
Compile with chpl bug.chpl $(./util/config/embed-python.sh)
The .these
iterator for lst
(which is an owned Value) does not resolve. Commenting out var arr: owned PyArray()?
allows for the code to resolve and run as expected
$CHPL_HOME/modules/packages/Python.chpl:3264: In iterator 'these':
$CHPL_HOME/modules/packages/Python.chpl:3265: error: Element type must be specified at compile time
iterate.chpl:1: called as (PyArray(nothing,-1)).these()
note: generic instantiations are underlined in the above callstack
This error doesn't make sense, its coming from the .these of PyArray, which is not invoked here. I think it is because PyArray is a child class of Value, so we resolve all methods of child classes which override a method from the parent class.
Not that adjusting this code to use a specific type for PyArray changes the error message.
use Python;
var interp = new Interpreter();
var lst = interp.get('list')(1, 2, 3);
var arr: owned PyArray(int)?;
for i in lst {
writeln(i);
}
Now the error is
$CHPL_HOME/modules/packages/Python.chpl:2314: error: conflicting return type specified for 'Value.these(): owned Value'
$CHPL_HOME/modules/packages/Python.chpl:3264: error: overridden by 'PyArray(?).these(): _ref(int(64))'
This issue is severely hampering the usability of the PyArray type and should be resolve. I am not sure if there is buggy behavior on the part of the language or just the library code, but we should resolve this issue.