Skip to content

Commit

Permalink
fix: handle parenthesized expressions in array length (#6132)
Browse files Browse the repository at this point in the history
# Description

## Problem

We were missing handling parenthesized expressions in
`UnresolvedTypeExpression::from_expr_helper`

## Summary

Fixes the above issue.

## Additional Context

## Documentation

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
asterite authored Sep 23, 2024
1 parent 5bf7352 commit 9f0b397
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/noirc_frontend/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ impl UnresolvedTypeExpression {
ExpressionKind::AsTraitPath(path) => {
Ok(UnresolvedTypeExpression::AsTraitPath(Box::new(path)))
}
ExpressionKind::Parenthesized(expr) => Self::from_expr_helper(*expr),
_ => Err(expr),
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "parenthesized_expression_in_array_length"
type = "bin"
authors = [""]
compiler_version = ">=0.32.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
global N = 100;
global BLOCK_SIZE = 10;

fn main() {
let _: [Field; 110] = [0; ((N + BLOCK_SIZE) * BLOCK_SIZE) / BLOCK_SIZE];
}

0 comments on commit 9f0b397

Please sign in to comment.