/* Make sure we raise an exception when we improperly call
 * a procedure which refers to a class variable (i.e. when
 * !(self ?= foo))
 */
class foo {
    var bletch = "Hello, world\n";
    public var bar;
    public proc nose(v) { v.bar = proc() { "", bletch; }; }
}

foo foobar();

proc main()
{
    var i;

    // Indirectly call the NIL foobar.bar - should succeed silently
    i = foobar.bar;
    i();

    // Indirectly call foobar.nose() - should succeed
    i = foobar.nose;
    i(foobar);

    // Directly call foobar.bar() - should print "Hello, world\n"
    foobar.bar();

    try {
        // Try to indirectly call foobar.bar - it should throw
        // an exception
        i = foobar.bar;
        i();
    }
    catch (e) {
        "Caught ", e, "; all is well\n";
    }
}