Open stonea opened 1 year ago
I reverse-engineered our existing rule as "Add-on 4" in https://github.com/chapel-lang/chapel/issues/17122#issuecomment-1516693176 . So, the following works:
type T = [0..1] int;
proc foo(arg : T) { writeln("Hello world"); }
var x = foo;
var y : [0..2] int;
x(y);
foo(y);
Apparently T
in the above is still generic w.r.t. the runtime domain value, even allowing different dimension sizes.
Luca encountered this on Gitter over the weekend:
why is this function considered generic?
use CTypes; proc normalize(ref ret: [1..3] real(64), const ref input: [1..3] real(64)): void { var tot = + reduce input; for i in ret.domain { ret[i] = input[i] / tot; } } var f = c_ptrTo(normalize);
When trying to convert that to a C pointer I get
error: the proc 'normalize' is generic and cannot be captured
For the following:
I get:
the proc 'foo' is generic and cannot be captured.
I suppose this is because the domain mapping for the array is unspecified?
However, even in the following program where we explicitly apply a mapping to 'x' as we do in
baz
, it errors out with the "proc is generic and can't be captured" error.Configuration Information