Skip to content

Borrowed references can survive borrowing-block #861

@EliasC

Description

@EliasC

It is possible to assign a borrowed variable to another variable declared outside of the borrowing scope:

read trait Hello
  def hello() : unit
    println("Hello, World!")
  end
end

linear class Foo : Hello
end

active class Main
  def main() : unit
    var x = new Foo
    var z = null : borrowed Foo
    borrow x as y in
      z = y -- This assignment should not be allowed!
    end
    -- z is now an alias of (the supposedly linear) x
    z.hello()
    x.hello()
  end
end

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions