Skip to content

Regression issue? #2002

Closed Answered by TomAFrench
skaunov asked this question in Q&A
Jul 22, 2023 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

I think this may be an error in the docs as bad_var's value is known for every step of program execution at compile time (the definition of a comptime variable).

A better example would be if you had a program similar to below

fn main(runtime_var: Field) -> pub Field {
    let known_at_compile_time: comptime Field = 1;

    // let inferred_known = 2;

    let bad_var: comptime Field = runtime_var;
    
    // known_at_compile_time + inferred_known
    known_at_compile_time + bad_var
}

As runtime_var is a argument to the circuit it cannot be known at compile time and so assigning it to a comptime variable should fail. A circuit's arguments is the only way in which non-comptime variables can…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@skaunov
Comment options

@Savio-Sou
Comment options

@TomAFrench
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by skaunov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants