Wiki

Ticket #356 (new defect)

Opened 11 years ago

Preconditions for methods that return a stream are not checked

Reported by: Charles Owned by:
Priority: major Milestone:
Component: Cobra Compiler Version: 0.9.6
Keywords: Cc:

Description

This program fails, but should succeed. The contract for .bar is never checked/executed at run-time:

class P

    var _last = ''
    
    def main
        .foo
        assert _last == 'foo'
        .bar
        for b in .bar, print b
        assert _last == 'bar'

    def foo as int
        require
            .required('foo')
        body
            return 0

    def bar as int*
        require
            .required('bar')
        body
            yield 1

    def required(name as String) as bool
        _last = name
        return true
Note: See TracTickets for help on using tickets.