Skip to content

option to avoid compiling a method that's known to throw for any input #3

@nsajko

Description

@nsajko

If a method is known to throw for any input, I think it would be good to avoid compiling it by default, or at least provide such an option.

Here's code that approximates the desired predicate of "known to throw":

function does_not_return(f, arg_types)
    Base.infer_return_type(f, arg_types) <: Union{}  # not public, sadly
end

function does_not_throw(f, arg_types)
    Base.infer_exception_type(f, arg_types) <: Union{}  # not public, sadly
end

function known_to_throw_unless_it_runs_forever(f, arg_types)
    may_throw = !does_not_throw(f, arg_types)
    may_throw && does_not_return(f, arg_types)
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions