Skip to content

Emit warnings for keywords selected to be reserved in the future - #16206

Merged
matheusaaguiar merged 4 commits into
developfrom
futureKeywordWarnings
Apr 29, 2026
Merged

Emit warnings for keywords selected to be reserved in the future#16206
matheusaaguiar merged 4 commits into
developfrom
futureKeywordWarnings

Conversation

@matheusaaguiar

@matheusaaguiar matheusaaguiar commented Sep 24, 2025

Copy link
Copy Markdown
Contributor

Partially solves #15795 and #14770.

@matheusaaguiar
matheusaaguiar force-pushed the futureKeywordWarnings branch 3 times, most recently from 586c3ca to 268a776 Compare October 3, 2025 18:17
@github-actions github-actions Bot added the stale The issue/PR was marked as stale because it has been open for too long. label Oct 18, 2025
@matheusaaguiar matheusaaguiar removed the stale The issue/PR was marked as stale because it has been open for too long. label Oct 20, 2025
@github-actions github-actions Bot added the stale The issue/PR was marked as stale because it has been open for too long. label Nov 11, 2025
@matheusaaguiar matheusaaguiar removed the stale The issue/PR was marked as stale because it has been open for too long. label Nov 11, 2025
@github-actions github-actions Bot added the stale The issue/PR was marked as stale because it has been open for too long. label Nov 26, 2025
@matheusaaguiar matheusaaguiar removed the stale The issue/PR was marked as stale because it has been open for too long. label Nov 26, 2025
Comment thread docs/assembly.rst Outdated
Comment thread libsolidity/analysis/SyntaxChecker.cpp Outdated
Comment thread test/libsolidity/syntaxTests/storageLayoutSpecifier/type_uint_max.sol Outdated
Comment thread libyul/AsmAnalysis.cpp Outdated
Comment thread libsolidity/analysis/SyntaxChecker.cpp Outdated
Comment on lines +538 to +539
"\"{}\" will be promoted to reserved keyword in the next breaking version"
" and will not be allowed as an identifier anymore.",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not necessarily something to change here, but just wanted to note that our terminology is all over the place: "keyword" vs "reserved keyword" vs "reserved identifier". We should get that straight at some point, because these are not synonyms.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True, I will try to align that and instead of "reserved keyword" use just "keyword" and not mix with "reserved identifiers".

@cameel cameel Nov 26, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd add a few more tests:

  • That the future keywords trigger the warning when used as:
    • module name (import ... as X or import * as X from ...)
    • alias name (import {... as X} from ...)
    • UDVT name
    • struct/enum field name
    • Yul variable/function name
  • That the future Yul keywords (i.e. leave) do trigger the warning outside of Yul.
    • It's actually up for discussion whether these should be reserved at Solidity level, but so far that has been the case with all other Yul keywords (including switch and let, which have no functionality in Solidity).
  • That the future Yul reserved identifiers (e.g. blobhash) do not trigger the warning outside of Yul.

@matheusaaguiar matheusaaguiar Jan 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have added some tests and verified that others cover the suggestions you made. Only thing that is missing is the point about Yul variable/function name, because keywords don't seem to trigger any error when used as identifiers in inline assembly and pure Yul.

That the future keywords trigger the warning when used as:

  • module name (import ... as X or import * as X from ...)

    • imports/import_name_future_keyword_warning.sol
  • alias name (import {... as X} from ...)

    • imports/import_alias_name_future_keyword_warning.sol
  • UDVT name

    • userDefinedValueType/udvt_name_future_keyword_warning.sol
  • struct/enum field name

    • syntaxTests/enums/enum_name_future_keyword_warning.sol
    • test/libsolidity/syntaxTests/structs/illegal_names.sol
    • test/libsolidity/syntaxTests/structs/struct_name_future_keyword_warning.sol
  • Yul variable/function name (?)

  • Solidity Keywords (or reserved) do not trigger any error or warning in assembly or pure Yul. Not sure if that is what you were suggesting.
    see yulSyntaxTests/solidity_keywords.yul and syntaxTests/inlineAssembly/solidity_keywords.sol
    leave is already a keyword in Yul.

That the future Yul keywords (i.e. leave) do trigger the warning outside of Yul.

  • test/libsolidity/syntaxTests/variableDeclaration/variable_named_leave.sol

That the future Yul reserved identifiers (e.g. blobhash) do not trigger the warning outside of Yul.

  • syntaxTests/globalFunctions/blobhash_function_pre_cancun.sol (already existent)
  • syntaxTests/globalFunctions/blobhash_var_shadow_warning.sol (already existent)
  • syntaxTests/globalFunctions/blobhash_function_shadow_warning.sol (already existent)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Solidity Keywords (or reserved) do not trigger any error or warning in assembly or pure Yul. Not sure if that is what you were suggesting.

Interesting. I was not aware of that. No need to change it then. It's a bit weird, but if it's not a bug but the way things were designed then it's fine.

Still good to have that covered with tests though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread docs/assembly.rst
Comment thread libsolidity/analysis/SyntaxChecker.cpp Outdated
@github-actions github-actions Bot added the stale The issue/PR was marked as stale because it has been open for too long. label Dec 11, 2025
@matheusaaguiar matheusaaguiar removed the stale The issue/PR was marked as stale because it has been open for too long. label Dec 11, 2025
@argotorg argotorg deleted a comment from github-actions Bot Dec 11, 2025
@argotorg argotorg deleted a comment from stackenbotten3000 Dec 15, 2025
@argotorg argotorg deleted a comment from stackenbotten3000 Dec 15, 2025
@argotorg argotorg deleted a comment from stackenbotten3000 Dec 15, 2025
@argotorg argotorg deleted a comment from stackenbotten3000 Dec 15, 2025
@argotorg argotorg deleted a comment from stackenbotten3000 Dec 15, 2025
@argotorg argotorg deleted a comment from stackenbotten3000 Dec 15, 2025
@argotorg argotorg deleted a comment from stackenbotten3000 Dec 15, 2025
@argotorg argotorg deleted a comment from stackenbotten3000 Dec 15, 2025
@matheusaaguiar
matheusaaguiar marked this pull request as ready for review December 17, 2025 14:06
@github-actions github-actions Bot added the stale The issue/PR was marked as stale because it has been open for too long. label Jan 1, 2026
@matheusaaguiar matheusaaguiar removed the stale The issue/PR was marked as stale because it has been open for too long. label Jan 5, 2026
@argotorg argotorg deleted a comment from github-actions Bot Jan 5, 2026
@matheusaaguiar
matheusaaguiar requested a review from cameel April 13, 2026 20:06
@matheusaaguiar

matheusaaguiar commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

@cameel , this should be ready to be merged.
( I think this was the last pending point: #16206 (comment))

@cameel

cameel commented Apr 18, 2026

Copy link
Copy Markdown
Collaborator

Sure, will take a look soon. Would be good to get this one into the next release.

@cameel cameel added this to the 0.8.35 milestone Apr 18, 2026
@argotorg argotorg deleted a comment from github-actions Bot Apr 28, 2026
cameel
cameel previously approved these changes Apr 28, 2026

@cameel cameel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is good for the most part. I have some change suggestions but they're minor enough (we could do away with some redundant warnings) that I think we can still merge this for the release and do them in a follow-up PR. So if you don't manage to resolve my comments today, feel free to merge and do just that.

Just make sure to apply the changelog suggestions.

Comment thread liblangutil/Token.cpp Outdated
Comment thread liblangutil/Token.cpp
Comment thread test/libsolidity/syntaxTests/duplicateFunctions/illegal_names_functions.sol Outdated
Comment thread Changelog.md Outdated
Comment thread docs/units-and-global-variables.rst Outdated
Comment thread Changelog.md Outdated
Comment thread Changelog.md Outdated
Comment thread liblangutil/Scanner.cpp Outdated
Comment thread liblangutil/Token.cpp Outdated
Comment thread libsolidity/analysis/NameAndTypeResolver.cpp Outdated
Comment thread test/libsolidity/syntaxTests/imports/import_alias_name_future_keyword_warning.sol Outdated
Comment thread libsolidity/analysis/NameAndTypeResolver.cpp Outdated
@argotorg argotorg deleted a comment from github-actions Bot Apr 28, 2026
@argotorg argotorg deleted a comment from github-actions Bot Apr 28, 2026
@argotorg argotorg deleted a comment from github-actions Bot Apr 28, 2026
@argotorg argotorg deleted a comment from github-actions Bot Apr 28, 2026
@matheusaaguiar
matheusaaguiar force-pushed the futureKeywordWarnings branch 2 times, most recently from ebdb163 to 7b49c7e Compare April 29, 2026 00:43
Comment thread libyul/optimiser/OptimizerUtilities.cpp Outdated
@matheusaaguiar
matheusaaguiar force-pushed the futureKeywordWarnings branch from 7b49c7e to a0c3652 Compare April 29, 2026 01:43
Comment thread liblangutil/Token.h Outdated
@matheusaaguiar
matheusaaguiar force-pushed the futureKeywordWarnings branch from a0c3652 to 5f6fbd4 Compare April 29, 2026 02:12
@matheusaaguiar
matheusaaguiar force-pushed the futureKeywordWarnings branch from 5f6fbd4 to ad2fda2 Compare April 29, 2026 02:13
@matheusaaguiar
matheusaaguiar merged commit b6cefb7 into develop Apr 29, 2026
83 checks passed
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.

5 participants