diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/mod.rs b/crates/noirc_evaluator/src/ssa/acir_gen/mod.rs index aca809a85fa..7409a199641 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/mod.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/mod.rs @@ -1121,7 +1121,7 @@ impl Context { #[cfg(test)] mod tests { - use std::{rc::Rc, collections::HashMap}; + use std::{collections::HashMap, rc::Rc}; use acvm::{ acir::{ diff --git a/crates/noirc_frontend/src/parser/errors.rs b/crates/noirc_frontend/src/parser/errors.rs index 9b072d83b09..af27f1445f7 100644 --- a/crates/noirc_frontend/src/parser/errors.rs +++ b/crates/noirc_frontend/src/parser/errors.rs @@ -25,8 +25,8 @@ pub enum ParserErrorReason { EarlyReturn, #[error("Patterns aren't allowed in a trait's function declarations")] PatternInTraitFunctionParameter, - #[error("Traits are an experimental feature that are not yet in a working state")] - TraitsAreExperimental, + #[error("{0} are experimental and aren't fully supported yet")] + ExperimentalFeature(&'static str), } /// Represents a parsing error, or a parsing error in the making. @@ -117,6 +117,11 @@ impl From for Diagnostic { "The 'constrain' keyword has been deprecated. Please use the 'assert' function instead.".into(), error.span, ), + ParserErrorReason::ExperimentalFeature(_) => Diagnostic::simple_warning( + reason.to_string(), + "".into(), + error.span, + ), reason @ ParserErrorReason::ExpectedPatternButFoundType(ty) => { Diagnostic::simple_error(reason.to_string(), format!("{ty} is a type and cannot be used as a variable name"), error.span) } diff --git a/crates/noirc_frontend/src/parser/parser.rs b/crates/noirc_frontend/src/parser/parser.rs index 6445205eae6..6e636ef9fa2 100644 --- a/crates/noirc_frontend/src/parser/parser.rs +++ b/crates/noirc_frontend/src/parser/parser.rs @@ -368,7 +368,7 @@ fn trait_definition() -> impl NoirParser { .then(trait_body()) .then_ignore(just(Token::RightBrace)) .validate(|((name, generics), items), span, emit| { - emit(ParserError::with_reason(ParserErrorReason::TraitsAreExperimental, span)); + emit(ParserError::with_reason(ParserErrorReason::ExperimentalFeature("Traits"), span)); TopLevelStatement::Trait(NoirTrait { name, generics, items }) }) } @@ -467,7 +467,7 @@ fn trait_implementation() -> impl NoirParser { let (((impl_generics, trait_name), trait_generics), (object_type, object_type_span)) = other_args; - emit(ParserError::with_reason(ParserErrorReason::TraitsAreExperimental, span)); + emit(ParserError::with_reason(ParserErrorReason::ExperimentalFeature("Traits"), span)); TopLevelStatement::TraitImpl(TraitImpl { impl_generics, trait_name, @@ -499,7 +499,7 @@ fn where_clause() -> impl NoirParser> { .then(ident()) .then(generic_type_args(parse_type())) .validate(|((typ, trait_name), trait_generics), span, emit| { - emit(ParserError::with_reason(ParserErrorReason::TraitsAreExperimental, span)); + emit(ParserError::with_reason(ParserErrorReason::ExperimentalFeature("Traits"), span)); TraitConstraint { typ, trait_name, trait_generics } }); @@ -878,7 +878,14 @@ fn int_type() -> impl NoirParser { Err(ParserError::expected_label(ParsingRuleLabel::IntegerType, unexpected, span)) } })) - .map(UnresolvedType::from_int_token) + .validate(|token, span, emit| { + let typ = UnresolvedType::from_int_token(token); + if let UnresolvedType::Integer(_, crate::Signedness::Signed, _) = &typ { + let reason = ParserErrorReason::ExperimentalFeature("Signed integer types"); + emit(ParserError::with_reason(reason, span)); + } + typ + }) } fn named_type(type_parser: impl NoirParser) -> impl NoirParser { @@ -1530,7 +1537,7 @@ mod test { "y[x+a]", " foo [foo+5]", "baz[bar]", - "foo.bar[3] as Field .baz as i32 [7]", + "foo.bar[3] as Field .baz as u32 [7]", ]; parse_all(atom_or_right_unary(expression(), expression_no_constructors(), true), valid); } @@ -1943,7 +1950,7 @@ mod test { #[test] fn parse_member_access() { - let cases = vec!["a.b", "a + b.c", "foo.bar as i32"]; + let cases = vec!["a.b", "a + b.c", "foo.bar as u32"]; parse_all(expression(), cases); }