New Issue: Lifetime of a 'const' borrow variable to ignore the variable's scope?

17317, "vasslitvinov", "Lifetime of a 'const' borrow variable to ignore the variable's scope?", "2021-03-02T20:04:39Z"

This issue proposes that given:

const b = RHS;  // RHS is some expression of a borrowed class type

the lifetime checker ignores the lexical scope of b, using only the scope of RHS as b's scope when reasoning about uses of b.

For example:

class list {
  var next: owned list?
var curr: borrowed list? = ....;
if curr != nil {
  const b = curr!;
  curr =;

currently produces an error because the lifetime of b, and therefore of, is considered to be the then-block of the if-statement, and so is shorter than the lifetime of curr. However, this restriction is just an artifact of the value of curr being stashed in a temporary variable.

The question to resolve here is: what invalid memory accesses would this rule enable (hopefully none)?