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

feat(experimental): Implement comptime mut globals #4926

Merged
merged 5 commits into from
Apr 29, 2024

Conversation

jfecher
Copy link
Contributor

@jfecher jfecher commented Apr 25, 2024

Description

Problem*

Resolves #4917

Summary*

Implements mutable comptime globals

Additional Context

Changes should be relatively straightforward - mostly parser changes to add parsing mut to globals, resolution changes to track this and error if the global is not also comptime, etc. The one bug that was fixed is that globals were being re-evaluated in the interpreter each time which would reset their value whenever they were referenced. This has been fixed with a lookup check.

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

span: let_stmt.pattern.span(),
});
let span = let_stmt.pattern.span();
self.push_err(ResolverError::AbiAttributeOusideContract { span });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is an old spelling error. Could we change it to Outside everywhere

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split this off here: #4933

}

fn main() {
// Order of comptime evaluation between functions isn't guaranteed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this guaranteed? Of course this would be a follow-up

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compiler/noirc_frontend/src/parser/parser.rs Show resolved Hide resolved
span: let_stmt.pattern.span(),
});
let span = let_stmt.pattern.span();
self.push_err(ResolverError::AbiAttributeOusideContract { span });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split this off here: #4933

}

fn main() {
// Order of comptime evaluation between functions isn't guaranteed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfecher jfecher merged commit dc90de9 into jf/comptime-globals Apr 29, 2024
41 checks passed
@jfecher jfecher deleted the jf/comptime-mut-globals branch April 29, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants