chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.77k stars 417 forks source link

(array)! to be compatible with array-typed formals #15080

Open vasslitvinov opened 4 years ago

vasslitvinov commented 4 years ago

Currently this code:

class Block {
  proc init(targetLocales: [] locale) {...}
}

var targetLocales: [....] locale?;
populate targetLocales;
... new Block(targetLocales!) ...

does not work because targetLocales! is a promoted expression and is not accepted for a formal of an array type.

We want to allow that, analogously to this case that works today:

var targetLocalesTemp: [....] locale?;
populate targetLocalesTemp;
var targetLocales: [] locale = targetLocalesTemp;

Test:

test/classes/nilability/bang-array.chpl
e-kayrakli commented 4 years ago

@vasslitvinov -- I played a bit with the associated future in test/classes/nilability/bang-array.chpl as part of #15149.

I think the issue here is actually #7936 and may not have anything to do with postfix-! ? For example the following doesn't compile and fail with the same error:

record C { 
  var x = 10;
  proc getX() {
    return x;
  }
}

var cs: [1..1] C;
bar(cs.getX());

proc bar(arrayArg: [] int) {
  writeln(arrayArg);
}

@mppf's comment here seems like the root cause of the problem.

Do you think there's something else that is going wrong with !?

vasslitvinov commented 4 years ago

@e-kayrakli your analysis makes sense to me.