Skip to content

fix(parser): let as have a lower precedence#8956

Merged
jfecher merged 3 commits intomasterfrom
ab/parser-cast-lower-precedence
Jun 18, 2025
Merged

fix(parser): let as have a lower precedence#8956
jfecher merged 3 commits intomasterfrom
ab/parser-cast-lower-precedence

Conversation

@asterite
Copy link
Collaborator

Description

Problem

Related to #8870

Summary

-128 as i8 was being parsed as -(128 as i8) which might be a bit unintuitive, and it's also different from Rust. This PR changes that so it's parsed as (-128) as i8.

That makes things a bit less intuitive in some cases because -128 as i16 is actually -127, but that's what you get if you also do let x: Field = -128; x as i16...

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.

Co-authored-by: Akosh Farkash <aakoshh@gmail.com>
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Compilation Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: df747a7 Previous: c0d47a5 Ratio
rollup-block-root-empty 23.2 s 18.66 s 1.24

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

@jfecher
Copy link
Contributor

jfecher commented Jun 18, 2025

That makes things a bit less intuitive in some cases because -128 as i16

Once we add types directly on integer literals this will be less of an issue at least

Copy link
Contributor

@jfecher jfecher left a comment

Choose a reason for hiding this comment

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

Let's just simplify the parser names.

They don't need to contain every rule. Usually a parser rule X includes X and any base cases. E.g. term includes not just multiplication terms but also atoms in other langs but they don't name it term_or_atom, etc.

@asterite
Copy link
Collaborator Author

This is ready for review again.

@jfecher jfecher added this pull request to the merge queue Jun 18, 2025
Merged via the queue into master with commit 71ab596 Jun 18, 2025
118 checks passed
@jfecher jfecher deleted the ab/parser-cast-lower-precedence branch June 18, 2025 18:06
github-merge-queue bot pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Jun 19, 2025
Automated pull of nightly from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
fix(defunctionalize): Create a placeholder function for first-class
function calls with no variants
(noir-lang/noir#8697)
fix(mem2reg): Keep store when any aliased reference is kept
(noir-lang/noir#8960)
fix(parser): let `as` have a lower precedence
(noir-lang/noir#8956)
fix: Match against all Value recursive types when checking for a
function/closure in a global
(noir-lang/noir#8967)
fix(formatter): reset indetnation after group changed it
(noir-lang/noir#8966)
chore(validation): Ban function pointers in SSA globals
(noir-lang/noir#8947)
chore: address various clippy issues
(noir-lang/noir#8942)
chore(fuzz): Consider `RangeCheckFailed` equivalent to
`ConstantDoesNotFitType` if the value matches
(noir-lang/noir#8958)
chore(fuzz): Use `nextest` to run nightly fuzz test
(noir-lang/noir#8962)
chore: minor code quality issues
(noir-lang/noir#8961)
END_COMMIT_OVERRIDE

---------

Co-authored-by: AztecBot <tech@aztecprotocol.com>
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
danielntmd pushed a commit to danielntmd/aztec-packages that referenced this pull request Jul 16, 2025
Automated pull of nightly from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
fix(defunctionalize): Create a placeholder function for first-class
function calls with no variants
(noir-lang/noir#8697)
fix(mem2reg): Keep store when any aliased reference is kept
(noir-lang/noir#8960)
fix(parser): let `as` have a lower precedence
(noir-lang/noir#8956)
fix: Match against all Value recursive types when checking for a
function/closure in a global
(noir-lang/noir#8967)
fix(formatter): reset indetnation after group changed it
(noir-lang/noir#8966)
chore(validation): Ban function pointers in SSA globals
(noir-lang/noir#8947)
chore: address various clippy issues
(noir-lang/noir#8942)
chore(fuzz): Consider `RangeCheckFailed` equivalent to
`ConstantDoesNotFitType` if the value matches
(noir-lang/noir#8958)
chore(fuzz): Use `nextest` to run nightly fuzz test
(noir-lang/noir#8962)
chore: minor code quality issues
(noir-lang/noir#8961)
END_COMMIT_OVERRIDE

---------

Co-authored-by: AztecBot <tech@aztecprotocol.com>
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.

4 participants