diff --git a/compiler/noirc_frontend/src/hir_def/types.rs b/compiler/noirc_frontend/src/hir_def/types.rs index a32be612b29..fe347661195 100644 --- a/compiler/noirc_frontend/src/hir_def/types.rs +++ b/compiler/noirc_frontend/src/hir_def/types.rs @@ -1277,13 +1277,13 @@ impl Type { Type::FieldElement | Type::Integer(_, _) | Type::Bool - | Type::Unit | Type::Constant(_, _) | Type::TypeVariable(_) | Type::NamedGeneric(_) | Type::Error => true, - Type::FmtString(_, _) + Type::Unit + | Type::FmtString(_, _) | Type::Function(_, _, _, _) | Type::Reference(..) | Type::Forall(_, _) diff --git a/test_programs/compile_failure/unit_in_main/Nargo.toml b/test_programs/compile_failure/unit_in_main/Nargo.toml new file mode 100644 index 00000000000..1b4ed14a6ed --- /dev/null +++ b/test_programs/compile_failure/unit_in_main/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "unit_in_main" +type = "bin" +authors = [""] +compiler_version = ">=0.33.0" + +[dependencies] diff --git a/test_programs/compile_failure/unit_in_main/src/main.nr b/test_programs/compile_failure/unit_in_main/src/main.nr new file mode 100644 index 00000000000..8f93bdcba45 --- /dev/null +++ b/test_programs/compile_failure/unit_in_main/src/main.nr @@ -0,0 +1 @@ +fn main(_: ()) {} diff --git a/test_programs/compile_failure/unit_in_main/stderr.txt b/test_programs/compile_failure/unit_in_main/stderr.txt new file mode 100644 index 00000000000..4c195dfbc1f --- /dev/null +++ b/test_programs/compile_failure/unit_in_main/stderr.txt @@ -0,0 +1,8 @@ +error: Only sized types may be used in the entry point to a program + ┌─ src/main.nr:1:12 + │ +1 │ fn main(_: ()) {} + │ -- Slices, references, or any type containing them may not be used in main, contract functions, or foldable functions + │ + +Aborting due to 1 previous error