-
Notifications
You must be signed in to change notification settings - Fork 761
feat: Allow identifiers to begin with _
#7243
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
Open
jbencin-stacks
wants to merge
34
commits into
stacks-network:pox-wf-integration
Choose a base branch
from
jbencin-stacks:feat/underscore-prefix
base: pox-wf-integration
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
8c5e78b
clarity6: allow leading-underscore identifiers, gated at Clarity 6
jbencin-stacks 73d0665
clarity6: bare `_` discard binding in `let` and `match`
jbencin-stacks 96bea09
clarity6: end-to-end tests + changelog for underscore identifiers
jbencin-stacks 03515ec
clarity6: collapse `_`-leading identifier arm into letter arm
jbencin-stacks ab2e348
Simplify changelog text
jbencin-stacks 9e2c066
clarity6: fix `<_foo>` trait refs + expand `underscore_checker` tests
jbencin-stacks b7978ce
Add more tests
jbencin-stacks 6a85e12
Add property test
jbencin-stacks 11f867e
Some code and comment cleanup
jbencin-stacks dcd782d
Disallow `_` as name except in `let`/`match`
jbencin-stacks 3d2c49a
Add `DISCARD_IDENTIFIER` constant
jbencin-stacks 3fc5f06
Disallow bare `_` in traits and tuple keys, and add tests
jbencin-stacks 5b851d0
Add test for nested `let` expressions using `_`
jbencin-stacks e2d2961
Replace "SIP-04x" -> "Clarity 6"
jbencin-stacks f732e54
Address PR feedback from Claude
jbencin-stacks a45bc01
Fix `handle_use_trait()`
jbencin-stacks fa0b46e
Fix CI
jbencin-stacks cdad1c4
Add `ClarityVersion::allows_leading_underscore()`
jbencin-stacks e3f1de9
clarity6: add ClarityNameV6 with codec + From/TryFrom conversions
jbencin-stacks 28a20d8
clarity6: replace ClarityNameV6 with LegacyClarityName (narrow type)
jbencin-stacks 750c868
clarity6: migrate TransactionContractCall.function_name to LegacyClar…
jbencin-stacks e9625b6
clarity6: migrate AssetInfo.asset_name to LegacyClarityName
jbencin-stacks db357cd
clarity6: gate `_`-prefixed tuple keys at transaction admission
jbencin-stacks 658adcb
Merge branch `stacks/pox-wf-integration` into `feat/underscore-prefix`
jbencin-stacks f25a3ec
Address Claude's PR comments
jbencin-stacks 271f49d
Drop `LegacyClarityName`, move `_`-rejection to admission walker
jbencin-stacks 042b1f4
Minor comment fixes
jbencin-stacks 41d482a
Run `cargo fmt-stacks` and add better error message if user tries to …
jbencin-stacks bf14795
Address Claude's PR comments
jbencin-stacks 54ae861
Fix error message
jbencin-stacks db6992e
Check for `_`-prefixed tuple keys in `from_consensus_buff()`
jbencin-stacks f1691e6
Merge branch `stacks/pox-wf-integration` into `feat/underscore-prefix`
jbencin-stacks 252bfe9
Address PR comment about deeply nested tuple keys
jbencin-stacks 13ed408
Change error message in snapshot so tests pass
jbencin-stacks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Clarity 6: Allow identifiers to begin with `_`, and allow bare `_` identifier in `let` and `match` bindings to discard value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned about changing this without a gate at this level. I think this could cause an accidental hard fork due to its use in wire-level validation. Like could a transaction with a leading
_somewhere get into a block that is accepted by updated nodes and rejected by unupdated nodes, before the epoch transition?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've got a point here, I can try to tighten this up and make better use the type system to "make invalid states unrepresentable"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm planning to fix by leaving the current
ClarityNamealone and creating a new struct,ClarityNameV6, which allows the leading underscore. This should be the safest and most correct way to proceed, as we'll never be able to use a leading_in the legacy code paths, but will also be a large diff@brice-stacks Let me know if this sounds right to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think that sounds good. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up not doing this as the diff would have been huge. Added admission checks in
StacksBlock::validate_transaction_static_epoch()insteadThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's still a potential divergence with runtime values. For example, a
from-consensus-buff?where the buffer encodes a tuple with a key starting with an_, e.g.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in f1691e6 by adding check in
from_consensus_buff()