Skip to content

Add support for experimental features in the parsing phase #7124

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
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ironcev
Copy link
Member

@ironcev ironcev commented Apr 27, 2025

Description

This PR brings support for experimental features to the parsing phase. This is needed so that we can support use cases like, e.g., adding new language keywords behind a feature flag.

A concrete example would be the panic keyword added in #7073. The parsing of the panic token differs if it is interpreted as a keyword (when the error_type experimental feature is active) or as a regular identifier (when error_type is off).

Because ExperimentalFeatures are needed in the Parse::parse(parser: &mut Parser) methods, the Parser got extended with the experimental field.

The consequence of bringing the ExperimentalFeatures to the parsing phase is, that swayfmt and forc fmt can also require an experimental feature to be set, to properly parse a project. In those tools, ExperimentalFeatures are passed as a field on the Formatter.

Note that this PR does not put the provided experimental flags into use. The first concrete usage will be in #7073.

This PR is a prerequisite for #7073.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@ironcev ironcev self-assigned this Apr 27, 2025
@ironcev ironcev added the compiler: parser Everything to do with the parser label Apr 27, 2025
@ironcev ironcev mentioned this pull request Apr 27, 2025
8 tasks
Copy link

codspeed-hq bot commented Apr 27, 2025

CodSpeed Performance Report

Merging #7124 will not alter performance

Comparing ironcev/experimental-features-in-parsing (a5317f3) with master (eb57cbf)

Summary

✅ 22 untouched benchmarks

@ironcev ironcev marked this pull request as ready for review April 27, 2025 16:51
@ironcev ironcev requested review from a team as code owners April 27, 2025 16:51
@ironcev ironcev enabled auto-merge (squash) April 27, 2025 16:52
@IGI-111 IGI-111 requested review from zees-dev and a team April 28, 2025 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: parser Everything to do with the parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants