Add failing test

This commit is contained in:
Pranav Gaddamadugu 2023-08-09 20:12:02 -04:00
parent d654182095
commit 7cc3330d98
4 changed files with 15 additions and 2 deletions

View File

@ -444,6 +444,7 @@ impl ParserContext<'_> {
// Eat a core struct constant or core struct function call.
expr = self.parse_associated_access_expression(expr)?;
} else if self.check(&Token::LeftParen) {
// TODO (@d0cd) Check that the xpression is an identifier
// Parse a function call that's by itself.
let (arguments, _, span) = self.parse_paren_comma_list(|p| p.parse_expression().map(Some))?;
expr = Expression::Call(CallExpression {

View File

@ -456,7 +456,7 @@ impl<'a> CodeGenerator<'a> {
// Lookup the function return type.
let function_name = match input.function.borrow() {
Expression::Identifier(identifier) => identifier.name,
_ => unreachable!("Parsing guarantees that all `input.function` is always an identifier."),
_ => unreachable!("Parsing guarantees that a function name is always an identifier."),
};
let return_type = &self.symbol_table.borrow().lookup_fn_symbol(function_name).unwrap().output_type;
match return_type {

View File

@ -453,6 +453,8 @@ impl<'a> ExpressionVisitor<'a> for TypeChecker<'a> {
}
fn visit_call(&mut self, input: &'a CallExpression, expected: &Self::AdditionalInput) -> Self::Output {
println!("call_expression: {}", input);
println!("input function: {:?}", input.function);
match &*input.function {
// Note that the parser guarantees that `input.function` is always an identifier.
Expression::Identifier(ident) => {
@ -514,7 +516,7 @@ impl<'a> ExpressionVisitor<'a> for TypeChecker<'a> {
None
}
}
_ => unreachable!("Parser guarantees that `input.function` is always an identifier."),
_ => unreachable!("Parsing guarantees that a function name is always an identifier."),
}
}

View File

@ -0,0 +1,10 @@
/*
namespace: Parse
expectation: Fail
*/
program test.aleo {
function x(x: u32, constant y: i32) -> u8 {
return 100u8(0u8);
}
}