-
Notifications
You must be signed in to change notification settings - Fork 225
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
Incorrect compiler error when returning an array after a code block #4372
Labels
bug
Something isn't working
Comments
TomAFrench
added a commit
that referenced
this issue
Oct 30, 2024
5 tasks
TomAFrench
added a commit
that referenced
this issue
Oct 30, 2024
* master: (30 commits) chore: add regression tests for #4372 (#6401) chore: add regression tests for #6314 (#6381) chore: use array instead of Vec in keccak256 (#6395) fix: make keccak256 work with input lengths greater than 136 bytes (#6393) feat: support specifying generics on a struct when calling an associated function (#6306) fix: Display every bit in integer tokens (#6360) feat: better LSP hover for functions (#6376) feat: Add capacities to brillig vectors and use them in slice ops (#6332) feat: suggest removing `!` from macro call that doesn't return Quoted (#6384) fix: (formatter) correctly format quote delimiters (#6377) fix: allow globals in format strings (#6382) feat: do not increment reference counts on arrays through references (#6375) fix: (LSP) check visibility of module that re-exports item, if any (#6371) feat: let LSP suggest traits in trait bounds (#6370) fix: LSP auto-import would import public item inside private module (#6366) fix: remove assumed parent traits (#6365) fix: slightly better formatting of empty blocks with comments (#6367) fix: Fix panic in comptime code (#6361) feat: let the LSP import code action insert into existing use statements (#6358) chore: minor tweaks to comptime doc (#6357) ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Aim
We (@FuzzingLabs) found that the compiler raises incorrectly an error when returning an array after a code block.
Expected Behavior
The error comes from the line 152 of this file: https://github.com/noir-lang/noir/blob/master/compiler/noirc_frontend/src/hir/type_check/errors.rs
No error should be returned.
Bug
The error occurs when attempting to return an array immediately after a code block. It persists under certain conditions, such as when using different array types, returning an array derived from a variable, or creating a code block with constructs other than an
if
statement, even if there are instructions inside them.However, there are workarounds to avoid this error. For instance, you can bypass the error by directly assigning the array to a variable before the code block, inserting an instruction between the code block and the return statement, or using an array with a specified size. Additionally, loop blocks do not trigger the error.
The error occurs with the latest compiler version on the master branch. The error message is as follows:
To Reproduce
nargo new test_issue
nargo compile
Project Impact
None
Impact Context
No response
Workaround
None
Workaround Description
No response
Additional Context
No response
Installation Method
None
Nargo Version
No response
NoirJS Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: