You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
comptime globals should also be mutable - unlike runtime globals currently.
Happy Case
comptime mut global COUNTER:Field = 0;
comptime fnget_unique_id() -> Field{let id = COUNTER;COUNTER += 1;
id
}fnid1() -> Field{comptime{ get_unique_id()}}fnid2() -> Field{comptime{ get_unique_id()}}fnmain(){// Order of comptime evaluation between functions isn't guaranteed// so we don't know if (id1 == 0 && id2 == 1) or if (id1 == 1 && id2 == 0).// we only know they are not equallet id1 = id1();let id2 = id2();assert(id1 != id2);}
Project Impact
None
Impact Context
No response
Workaround
None
Workaround Description
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered:
# 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.
- [x] **[For Experimental Features]** Documentation to be submitted in a
separate PR.
# PR Checklist\*
- [x] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
---------
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
Problem
comptime
globals should also be mutable - unlike runtime globals currently.Happy Case
Project Impact
None
Impact Context
No response
Workaround
None
Workaround Description
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: