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

Add "ensure" and "invariant" checking for contract based assertions and static analysis #15390

Closed
DartBot opened this issue Nov 30, 2013 · 5 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Nov 30, 2013

This issue was originally filed by rona...@gmail.com


I am a big fan of the Code Contracts (http://msdn.microsoft.com/en-us/library/dd264808(v=vs.110).aspx) functionality that Microsoft have added to .NET and would love to see something similar in Dart.

I would guess a first step would be to in addition to "assert" also add "ensure" and "invariant" test in runtime and later on also allow it to help static analysis.

@kasperl
Copy link

kasperl commented Dec 4, 2013

Added Area-Library, Triaged labels.

@lrhn
Copy link
Member

lrhn commented Dec 4, 2013

Removed Type-Defect, Area-Library labels.
Added Type-Enhancement, Area-Language labels.

@DartBot
Copy link
Author

DartBot commented Dec 9, 2013

This comment was originally written by ro...@gmail.com


To illustrate how one would do this without language support:

class Foo
{
    Foo()
    {
         checkInvariants();
         assert(/* requirement */);

         try
         {
             /* implementation /
         }
         finally
         {
              assert(/
ensures */);
              checkInvariants();
         }
    }

    void checkInvariants()
    {
         assert(/* invariant */);
    }
}

Which gives a lot of code clutter...

@DartBot
Copy link
Author

DartBot commented Dec 9, 2013

This comment was originally written by ronag...@gmail.com


Instead of something like:

class Foo
{
    Foo()
    {
        requires
        {
            /* requirement /
        }
        
        ensures
        {
            /
ensures /
        }
        
         /
implementation /
    }
    
    invariants
    {
         /
invariant */;
    }
}

@gbracha
Copy link
Contributor

gbracha commented Jan 2, 2015

Added Duplicate label.
Marked as being merged into #3049.

@DartBot DartBot added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report labels Jan 2, 2015
@gbracha gbracha mentioned this issue Jun 3, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants