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

Option to copy over specifications for traits #2930

Open
seebees opened this issue Oct 26, 2022 · 3 comments
Open

Option to copy over specifications for traits #2930

seebees opened this issue Oct 26, 2022 · 3 comments
Labels
kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny misc: language proposals Proposals for change to the language that go beyon simple enhancement requests part: resolver Resolution and typechecking

Comments

@seebees
Copy link

seebees commented Oct 26, 2022

When working with abstract modules the specifications are copied over automatically.
It would be nice to add something similar for trait .

@robin-aws
Copy link
Member

You're proposing a workaround for #2500 I assume? Do you mean literally copy the text of the specifications from a trait into the definition of a class that extends it?

@seebees
Copy link
Author

seebees commented Oct 26, 2022

Not quite.

I don't see any reason per se
that Dafny requires that I copy these things over.
I'm guessing that the implementation detail
of how abstract module literally copies code is in play,
but the customer experience should be the same yes?

The following currently fails
with the method must provide an equal or more detailed postcondition than in its parent trait.
I'm proposing that it would succeed.

  trait Foo {
    method Bar() returns (i: int)
      ensures 10 < i < 100
  }

  class {:magic} Baz extends Foo {

    method Bar() returns (i: int)
    {
      return 15;
    }
  }

Similar to

abstract module Foo {

  method Bar() returns (i: int)
    ensures 10 < i < 100

}

module Baz refines Foo {

  method Bar() returns (i: int)
  {
    return 15;
  }

}

@atomb atomb added kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny part: resolver Resolution and typechecking misc: language proposals Proposals for change to the language that go beyon simple enhancement requests labels Oct 26, 2022
@robin-aws
Copy link
Member

Ah got it, thanks for clarifying. So this would be a usability improvement to avoid having to copy text around.

Reasonable idea, but I know this is coming up in the context of #2500 - I'm going to update that issue and continue discussion about how to fix that issue specifically, which may or may not involve this feature.

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 misc: language proposals Proposals for change to the language that go beyon simple enhancement requests part: resolver Resolution and typechecking
Projects
None yet
Development

No branches or pull requests

3 participants