Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for explicitly pass this receiver as a parameter of method #5889

Open
Ao-senXiong opened this issue Nov 1, 2024 · 0 comments
Open
Labels
kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny

Comments

@Ao-senXiong
Copy link
Contributor

Summary

Consider the following Example method, which already use this receiver in the method body.

class C {
  var f: int
  var x: int
  method Example() returns (b: bool)
  {
    var x: int;
    b := f == this.f;
  }
}

However, Dafny current does not support explicit pass this receiver as a parameter like the following and reject the code.

  method Example(this: C) returns (b: bool)
  {
    var x: int;
    b := f == this.f;
  }

Background and Motivation

Rustan mentioned there could be two potential use of it.

  1. Support extension method in the future.
  2. Use it as a nullable receiver this: C?.

Proposed Feature

Explicit pass in this should not be rejected by the compiler and should behave the same as use this for field read and write directly.

Alternatives

No response

@Ao-senXiong Ao-senXiong added the kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny
Projects
None yet
Development

No branches or pull requests

1 participant