Skip to content

feat(experimental): Implement comptime mut globals#4926

Merged
jfecher merged 5 commits intojf/comptime-globalsfrom
jf/comptime-mut-globals
Apr 29, 2024
Merged

feat(experimental): Implement comptime mut globals#4926
jfecher merged 5 commits intojf/comptime-globalsfrom
jf/comptime-mut-globals

Conversation

@jfecher
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

span: let_stmt.pattern.span(),
});
let span = let_stmt.pattern.span();
self.push_err(ResolverError::AbiAttributeOusideContract { span });
Copy link
Copy Markdown
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
Copy Markdown
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
@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