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

Disallow return values from being constants #655

Closed
kevaundray opened this issue Jan 17, 2023 · 3 comments · Fixed by #2978
Closed

Disallow return values from being constants #655

kevaundray opened this issue Jan 17, 2023 · 3 comments · Fixed by #2978
Assignees
Labels
discussion enhancement New feature or request

Comments

@kevaundray
Copy link
Contributor

Problem

The current program:

fn main(x : Field) -> [Field;2] {
  [x, 2]
}

Will allow the user to return a constant as a public output.

Solution

Users will need to differentiate between a program constant and a public output(which is public and will vary).

ie you cannot return a constant as a public output.

Alternatives considered

Additional context

This is a tracking issue to collect feedback

@kevaundray kevaundray added enhancement New feature or request discussion labels Jan 17, 2023
@jfecher
Copy link
Contributor

jfecher commented Jan 17, 2023

Can you elaborate on the context for this issue? We have discussed it a bit in private but without the context given here it sounds like an arbitrary restriction to place.

@guipublic
Copy link
Contributor

IHMO, returning [x,2] is NOT a problem per se.

The way we handle this case is by creating a witness which is constrained to the hardcoded value (2 in the example).
This is fine because it corresponds to what the user wrote and it is safe.
We could however issue a warning explaining that this value does not need to be returned because it is always 2.

@kevaundray
Copy link
Contributor Author

@guipublic I have assigned this to you -- you can choose to issue a warning or disallow. I don't think it matters that much right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants