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

Separate functions from comptime functions in the type system #5201

Open
Tracked by #4594
jfecher opened this issue Jun 7, 2024 · 0 comments
Open
Tracked by #4594

Separate functions from comptime functions in the type system #5201

jfecher opened this issue Jun 7, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@jfecher
Copy link
Contributor

jfecher commented Jun 7, 2024

Problem

It is possible for comptime functions to not be found and evaluated at compile-time, e.g:

let bad = my_comptime_only_function;
bad(); // Call is not registered as comptime

Happy Case

comptime functions are assigned a different type from regular functions: comptime fn(). This can then be checked for when calling functions to determine whether to do so at compile-time or not, and can also be used to issue an error if it cannot be evaluated at compile-time do to being mixed in runtime code, e.g:

fn main(x: bool) {
    if x {
        my_comptime_fn1
    } else {
        my_comptime_fn2
    }();
}

Project Impact

None

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@jfecher jfecher added the enhancement New feature or request label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant