Skip to content

Make persistent/temporary/instance keywords target-aware (fixes #1847)#1858

Open
Sukuna0007Abhi wants to merge 1 commit intohyperledger-solang:mainfrom
Sukuna0007Abhi:fix/1847-soroban-parser-compat
Open

Make persistent/temporary/instance keywords target-aware (fixes #1847)#1858
Sukuna0007Abhi wants to merge 1 commit intohyperledger-solang:mainfrom
Sukuna0007Abhi:fix/1847-soroban-parser-compat

Conversation

@Sukuna0007Abhi
Copy link
Copy Markdown

Fixes #1847

PR #1664 added persistent, temporary, and instance as global keywords, which breaks
any Solidity code using these as identifiers on non-Soroban targets (e.g. uint256 persistent = 0;).

This fix makes the lexer target-aware, as suggested by @seanyoung. The three words are only
treated as keywords when targeting Soroban, and fall back to plain identifiers for all other targets.

Changes:

  • solang-parser/src/lexer.rs — added soroban: bool flag; keyword lookup skips the three tokens when flag is off
  • solang-parser/src/lib.rs — added parse_soroban() alongside existing parse(); shared logic in parse_internal()
  • src/sema/mod.rs — dispatches to parse_soroban() when ns.target == Soroban, parse() otherwise
  • solang-parser/src/tests.rs — two regression tests: identifiers pass in default, keywords pass in soroban

Testing:

  • All 18 parser unit tests pass
  • All 4 doc-tests pass
  • cargo fmt --check clean

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.

Solang parser incompatibility from introducing Soroban storage types

1 participant