Skip to content
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

fix: Parse a statement as an expression #6040

Merged
merged 3 commits into from
Sep 13, 2024
Merged

Conversation

jfecher
Copy link
Contributor

@jfecher jfecher commented Sep 13, 2024

Description

Problem*

Resolves #6036

Summary*

Grego was having an issue from some macros where some code was taken from a block and later put in the rhs of a let statement: let _ = $former_block_statement. Since this expression originated from a block statement though, it is a Token::InternedStatement and not a valid expression.

I've updated the parser to accept interned statements in an expression position, and we just later validate that they're either StatementKind::Expression or StatementKind::Semi nodes.

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@jfecher jfecher requested a review from a team September 13, 2024 19:38
Copy link
Contributor

github-actions bot commented Sep 13, 2024

Changes to Brillig bytecode sizes

Generated at commit: b42304f74ecf93b7bf592faa3cd01c3328cfa767, compared to commit: 57afc7ddd424220106af7b9c6e0715007f6ea8b8

There are no changes in circuit sizes

Copy link
Collaborator

@asterite asterite left a comment

Choose a reason for hiding this comment

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

Looks good!

@jfecher jfecher changed the title Parse a statement as an expression fix: Parse a statement as an expression Sep 13, 2024
@jfecher jfecher added this pull request to the merge queue Sep 13, 2024
Merged via the queue into master with commit ab203e4 Sep 13, 2024
46 checks passed
@jfecher jfecher deleted the jf/parse-statement-as-expr branch September 13, 2024 20:12
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request Sep 14, 2024
…ang/noir#6039)

fix: Fix canonicalization bug (noir-lang/noir#6033)
fix: Parse a statement as an expression (noir-lang/noir#6040)
chore: rename CustomAtrribute to CustomAttribute (noir-lang/noir#6038)
fix: error on `&mut x` when `x` is not mutable (noir-lang/noir#6037)
feat: add `Expr::as_constructor` (noir-lang/noir#5980)
chore: Fix docs (noir-lang/noir#6035)
chore: document array methods (noir-lang/noir#6034)
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request Sep 15, 2024
…ang/noir#6039)

fix: Fix canonicalization bug (noir-lang/noir#6033)
fix: Parse a statement as an expression (noir-lang/noir#6040)
chore: rename CustomAtrribute to CustomAttribute (noir-lang/noir#6038)
fix: error on `&mut x` when `x` is not mutable (noir-lang/noir#6037)
feat: add `Expr::as_constructor` (noir-lang/noir#5980)
chore: Fix docs (noir-lang/noir#6035)
chore: document array methods (noir-lang/noir#6034)
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request Sep 15, 2024
fix: Fix canonicalization bug (noir-lang/noir#6033)
fix: Parse a statement as an expression (noir-lang/noir#6040)
chore: rename CustomAtrribute to CustomAttribute (noir-lang/noir#6038)
fix: error on `&mut x` when `x` is not mutable (noir-lang/noir#6037)
feat: add `Expr::as_constructor` (noir-lang/noir#5980)
chore: Fix docs (noir-lang/noir#6035)
chore: document array methods (noir-lang/noir#6034)
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request Sep 16, 2024
…ang/noir#6039)

fix: Fix canonicalization bug (noir-lang/noir#6033)
fix: Parse a statement as an expression (noir-lang/noir#6040)
chore: rename CustomAtrribute to CustomAttribute (noir-lang/noir#6038)
fix: error on `&mut x` when `x` is not mutable (noir-lang/noir#6037)
feat: add `Expr::as_constructor` (noir-lang/noir#5980)
chore: Fix docs (noir-lang/noir#6035)
chore: document array methods (noir-lang/noir#6034)
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request Sep 16, 2024
fix: Fix canonicalization bug (noir-lang/noir#6033)
fix: Parse a statement as an expression (noir-lang/noir#6040)
chore: rename CustomAtrribute to CustomAttribute (noir-lang/noir#6038)
fix: error on `&mut x` when `x` is not mutable (noir-lang/noir#6037)
feat: add `Expr::as_constructor` (noir-lang/noir#5980)
chore: Fix docs (noir-lang/noir#6035)
chore: document array methods (noir-lang/noir#6034)
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request Sep 17, 2024
…oir-lang/noir#6051)

feat(metaprogramming): Add `#[use_callers_scope]` (noir-lang/noir#6050)
feat: show test output when running via LSP (noir-lang/noir#6049)
feat: add `Expr::as_lambda` (noir-lang/noir#6048)
feat: faster LSP by caching file managers (noir-lang/noir#6047)
feat: implement `to_be_radix` in the comptime interpreter (noir-lang/noir#6043)
fix: prevent check_can_mutate crashing on undefined variable (noir-lang/noir#6044)
feat: add `Expr::as_for` and `Expr::as_for_range` (noir-lang/noir#6039)
fix: Fix canonicalization bug (noir-lang/noir#6033)
fix: Parse a statement as an expression (noir-lang/noir#6040)
chore: rename CustomAtrribute to CustomAttribute (noir-lang/noir#6038)
fix: error on `&mut x` when `x` is not mutable (noir-lang/noir#6037)
feat: add `Expr::as_constructor` (noir-lang/noir#5980)
chore: Fix docs (noir-lang/noir#6035)
chore: document array methods (noir-lang/noir#6034)
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request Sep 17, 2024
…oir#6051)

feat(metaprogramming): Add `#[use_callers_scope]` (noir-lang/noir#6050)
feat: show test output when running via LSP (noir-lang/noir#6049)
feat: add `Expr::as_lambda` (noir-lang/noir#6048)
feat: faster LSP by caching file managers (noir-lang/noir#6047)
feat: implement `to_be_radix` in the comptime interpreter (noir-lang/noir#6043)
fix: prevent check_can_mutate crashing on undefined variable (noir-lang/noir#6044)
feat: add `Expr::as_for` and `Expr::as_for_range` (noir-lang/noir#6039)
fix: Fix canonicalization bug (noir-lang/noir#6033)
fix: Parse a statement as an expression (noir-lang/noir#6040)
chore: rename CustomAtrribute to CustomAttribute (noir-lang/noir#6038)
fix: error on `&mut x` when `x` is not mutable (noir-lang/noir#6037)
feat: add `Expr::as_constructor` (noir-lang/noir#5980)
chore: Fix docs (noir-lang/noir#6035)
chore: document array methods (noir-lang/noir#6034)
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request Sep 17, 2024
feat: allow visibility modifiers in struct definitions (noir-lang/noir#6054)
fix: let LSP suggest fields and methods in LValue chains (noir-lang/noir#6051)
feat(metaprogramming): Add `#[use_callers_scope]` (noir-lang/noir#6050)
feat: show test output when running via LSP (noir-lang/noir#6049)
feat: add `Expr::as_lambda` (noir-lang/noir#6048)
feat: faster LSP by caching file managers (noir-lang/noir#6047)
feat: implement `to_be_radix` in the comptime interpreter (noir-lang/noir#6043)
fix: prevent check_can_mutate crashing on undefined variable (noir-lang/noir#6044)
feat: add `Expr::as_for` and `Expr::as_for_range` (noir-lang/noir#6039)
fix: Fix canonicalization bug (noir-lang/noir#6033)
fix: Parse a statement as an expression (noir-lang/noir#6040)
chore: rename CustomAtrribute to CustomAttribute (noir-lang/noir#6038)
fix: error on `&mut x` when `x` is not mutable (noir-lang/noir#6037)
feat: add `Expr::as_constructor` (noir-lang/noir#5980)
chore: Fix docs (noir-lang/noir#6035)
chore: document array methods (noir-lang/noir#6034)
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request Sep 17, 2024
feat: allow visibility modifiers in struct definitions (noir-lang/noir#6054)
fix: let LSP suggest fields and methods in LValue chains (noir-lang/noir#6051)
feat(metaprogramming): Add `#[use_callers_scope]` (noir-lang/noir#6050)
feat: show test output when running via LSP (noir-lang/noir#6049)
feat: add `Expr::as_lambda` (noir-lang/noir#6048)
feat: faster LSP by caching file managers (noir-lang/noir#6047)
feat: implement `to_be_radix` in the comptime interpreter (noir-lang/noir#6043)
fix: prevent check_can_mutate crashing on undefined variable (noir-lang/noir#6044)
feat: add `Expr::as_for` and `Expr::as_for_range` (noir-lang/noir#6039)
fix: Fix canonicalization bug (noir-lang/noir#6033)
fix: Parse a statement as an expression (noir-lang/noir#6040)
chore: rename CustomAtrribute to CustomAttribute (noir-lang/noir#6038)
fix: error on `&mut x` when `x` is not mutable (noir-lang/noir#6037)
feat: add `Expr::as_constructor` (noir-lang/noir#5980)
chore: Fix docs (noir-lang/noir#6035)
chore: document array methods (noir-lang/noir#6034)
TomAFrench added a commit to AztecProtocol/aztec-packages that referenced this pull request Sep 17, 2024
Automated pull of development from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
feat: add `Expr::as_for` and `Expr::as_for_range`
(noir-lang/noir#6039)
fix: Fix canonicalization bug
(noir-lang/noir#6033)
fix: Parse a statement as an expression
(noir-lang/noir#6040)
chore: rename CustomAtrribute to CustomAttribute
(noir-lang/noir#6038)
fix: error on `&mut x` when `x` is not mutable
(noir-lang/noir#6037)
feat: add `Expr::as_constructor`
(noir-lang/noir#5980)
chore: Fix docs (noir-lang/noir#6035)
chore: document array methods
(noir-lang/noir#6034)
END_COMMIT_OVERRIDE

---------

Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
AztecBot added a commit to AztecProtocol/aztec-nr that referenced this pull request Sep 18, 2024
Automated pull of development from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
feat: add `Expr::as_for` and `Expr::as_for_range`
(noir-lang/noir#6039)
fix: Fix canonicalization bug
(noir-lang/noir#6033)
fix: Parse a statement as an expression
(noir-lang/noir#6040)
chore: rename CustomAtrribute to CustomAttribute
(noir-lang/noir#6038)
fix: error on `&mut x` when `x` is not mutable
(noir-lang/noir#6037)
feat: add `Expr::as_constructor`
(noir-lang/noir#5980)
chore: Fix docs (noir-lang/noir#6035)
chore: document array methods
(noir-lang/noir#6034)
END_COMMIT_OVERRIDE

---------

Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
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.

Quoted Exprs from blocks fail to parse back into expressions
2 participants