You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compile a program with a locally mutable parameter, where the 'mut' keyword has been incorrectly placed inside the type: fn test_fn(q: mut u32) { } (instead of the correct fn test_fn(mut q: u32) { }) and get a reasonable (understandable by a human) compiler error.
Expected Behavior
The program should produce a readable compile error. For example, Rust produces this error:
error: expected type, found keyword `mut`
--> src/main.rs:1:18
|
1 | fn test_param(q: mut u32) {
| ^^^ expected type
Bug
Noir produces a bogus warning about unnecessary pub keyword, followed by a long list of (mostly) spurious errors:
warning: unnecessary pub keyword on parameter for function test_fn
┌─ main.nr:1:4
│
1 │ fn test_fn(q: mut u32) {
│ ------- unnecessary pub parameter
│
= The `pub` keyword only has effects on arguments to the entry-point function of a program. Thus, adding it to other function parameters can be deceiving and should be removed
warning: unused variable q
┌─ main.nr:1:12
│
1 │ fn test_fn(q: mut u32) {
│ - unused variable
│
warning: unused variable main
┌─ main.nr:4:4
│
4 │ fn main(x: Field, y: pub Field) {
│ ---- unused variable
│
warning: unused function test_fn
┌─ main.nr:1:4
│
1 │ fn test_fn(q: mut u32) {
│ ------- unused function
│
error: Cannot assign an expression of type (_) to a value of type Field
┌─ main.nr:4:8
│
4 │ fn main(x: Field, y: pub Field) {
│ --
│
error: Expected a type but found 'mut'
┌─ main.nr:1:15
│
1 │ fn test_fn(q: mut u32) {
│ ---
│
error: Expected a pattern but found a type - u32
┌─ main.nr:1:19
│
1 │ fn test_fn(q: mut u32) {
│ --- u32 is a type and cannot be used as a variable name
│
error: Expected a pattern but found 'u32'
┌─ main.nr:1:19
│
1 │ fn test_fn(q: mut u32) {
│ ---
│
error: Expected a pattern but found ')'
┌─ main.nr:1:22
│
1 │ fn test_fn(q: mut u32) {
│ -
│
error: Expected a pattern but found '{'
┌─ main.nr:1:24
│
1 │ fn test_fn(q: mut u32) {
│ -
│
error: Expected a pattern but found '}'
┌─ main.nr:2:1
│
2 │ }
│ -
│
error: Expected a pattern but found 'fn'
┌─ main.nr:4:1
│
4 │ fn main(x: Field, y: pub Field) {
│ --
│
error: Missing type for function parameter
┌─ main.nr:4:4
│
4 │ fn main(x: Field, y: pub Field) {
│ -----
│
error: Expected a `,` separating these two parameters
┌─ main.nr:1:15
│
1 │ fn test_fn(q: mut u32) {
│ ---
│
error: Expected a pattern but found ':'
┌─ main.nr:4:10
│
4 │ fn main(x: Field, y: pub Field) {
│ -
│
error: Expected a `,` separating these two parameters
┌─ main.nr:4:8
│
4 │ fn main(x: Field, y: pub Field) {
│ -
│
Aborting due to 12 previous errors
To Reproduce
Create a new nargo package: nargo new mut_param
Edit main.nr and replace it with the following code:
Aim
Compile a program with a locally mutable parameter, where the 'mut' keyword has been incorrectly placed inside the type:
fn test_fn(q: mut u32) { }
(instead of the correctfn test_fn(mut q: u32) { }
) and get a reasonable (understandable by a human) compiler error.Expected Behavior
The program should produce a readable compile error. For example, Rust produces this error:
Bug
Noir produces a bogus warning about unnecessary
pub
keyword, followed by a long list of (mostly) spurious errors:To Reproduce
nargo new mut_param
main.nr
and replace it with the following code:nargo compile
and observe the list of errors.Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
Nice-to-have
Blocker Context
No response
Nargo Version
No response
NoirJS Version
No response
Proving Backend Tooling & 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: