ASDAlexander77 / TypeScriptCompiler

TypeScript Compiler (by LLVM)
MIT License
588 stars 28 forks source link

the following code can't be compiled #87

Closed ASDAlexander77 closed 9 months ago

ASDAlexander77 commented 10 months ago
let called = false;

function may_throw(a = 0) {
    if (a > 100) throw 1;
}

class TempFile {
    #path: string;
    #handle: number;
    constructor(path: string) {
        this.#path = path;
        this.#handle = 1;
    }
    // other methods
    [Symbol.dispose]() {
        // Close the file and delete it.
        this.#handle = 0;
        print("dispose");
    }
}

function func1() {
    try {
    using file = new TempFile(".some_temp_file");
        print("In try");
        may_throw(1000);
    }
    catch (e: TypeOf<1>)
    {
    print("catch");
    return;
    }
    finally {
        print("finally");
        called = true;
    }

    called = false;
    print("end");
}

function main() {
    func1();
    assert(called, "finally is not called");
    print("done.");
}
ASDAlexander77 commented 9 months ago

fixed, will be in main branch soon