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 methods not in a contract scope to call methods in contract scope #955

Closed
kevaundray opened this issue Mar 6, 2023 · 0 comments · Fixed by #980
Closed

Disallow methods not in a contract scope to call methods in contract scope #955

kevaundray opened this issue Mar 6, 2023 · 0 comments · Fixed by #980
Assignees
Labels
enhancement New feature or request

Comments

@kevaundray
Copy link
Contributor

Problem

Methods and state variables in a contract scope have functionality and semantics that does not apply when you are not speaking about contracts.

Consider the following program copied from Jake's awesome PR:

fn main(x : Field, y : pub Field) {
     constrain Foo::xy(x) == Foo::triple(y);
 }

 contract Foo {
      y : Field
     fn double(x: Field) -> Field { x * 2 }
     fn xy(x: Field) -> Field { x * y }
 }

Calling xy outside a contract brings forth a few question:

  • What does it mean when one calls xy and accesses the state variable y in this context?
  • Does this behaviour differ in anyways if xy was called by another contract?
  • Can a regular Noir program modify the state of y?

I think we could possibly define semantics for this however since there is no usecase for it and it would lead to additional complexity, its better to not allow it now and allow it in the future if we need to.

Proposed solution

Noir contracts can call other contracts and programs. However, Noir programs cannot call Noir contracts.

Alternatives considered

No response

Additional context

No response

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
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants