diff --git a/compiler/noirc_frontend/src/tests/turbofish.rs b/compiler/noirc_frontend/src/tests/turbofish.rs index 586559600fd..3f21ef23503 100644 --- a/compiler/noirc_frontend/src/tests/turbofish.rs +++ b/compiler/noirc_frontend/src/tests/turbofish.rs @@ -591,3 +591,80 @@ fn errors_on_incorrect_turbofish_on_struct() { "#; check_errors(src); } + +#[test] +fn incorrect_turbofish_count_on_primitive_u8() { + let src = r#" + trait From { + fn from(x: T) -> Self; + } + + impl From for u8 { + fn from(x: Field) -> Self { + x as u8 + } + } + + fn main() { + let _ = u8::::from(5); + ^^^^^^^^^^^^ u8 expects 0 generics but 2 were given + } + "#; + check_errors(src); +} + +#[test] +fn incorrect_turbofish_count_on_primitive_str() { + let src = r#" + trait MyTrait { + fn foo(); + } + + impl MyTrait for str { + fn foo() { } + } + + fn main() { + let _ = str::<5, u32>::foo(); + ^^^^^^^^^^ primitive type str expects 1 generic but 2 were given + } + "#; + check_errors(src); +} + +#[test] +fn incorrect_turbofish_count_on_primitive_fmtstr() { + let src = r#" + trait MyTrait { + fn foo(); + } + + impl MyTrait for fmtstr { + fn foo() { } + } + + fn main() { + let _ = fmtstr::<5>::foo(); + ^^^^^ primitive type fmtstr expects 2 generics but 1 was given + } + "#; + check_errors(src); +} + +#[test] +fn turbofish_on_primitive_fmtstr() { + let src = r#" + trait MyTrait { + fn foo(); + } + + impl MyTrait for fmtstr { + fn foo() { } + } + + fn main() { + let _ = fmtstr::<5, Field>::foo(); + } + "#; + check_errors(src); +}