diff --git a/crates/cairo-lang-semantic/src/expr/test_data/inline_macros b/crates/cairo-lang-semantic/src/expr/test_data/inline_macros index 978cc85bfc9..0e190f0a4a1 100644 --- a/crates/cairo-lang-semantic/src/expr/test_data/inline_macros +++ b/crates/cairo-lang-semantic/src/expr/test_data/inline_macros @@ -635,6 +635,9 @@ fn foo() { // Unused arguments. print!("{2}{0}", ba, 2, 1); + + // Missing parens. + print!; } //! > function_name @@ -643,6 +646,11 @@ foo //! > module_code //! > expected_diagnostics +error: Missing tokens. Expected an argument list wrapped in either parentheses, brackets, or braces. + --> lib.cairo:32:11 + print!; + ^ + error: Plugin diagnostic: Macro `write` does not support this bracket type. --> lib.cairo:5:11 print!["{}", ba]; @@ -688,6 +696,16 @@ error: Plugin diagnostic: Unused argument. print!("{2}{0}", ba, 2, 1); ^ +error: Plugin diagnostic: Macro `write` does not support this bracket type. + --> lib.cairo:32:11 + print!; + ^ + +error: Wrong number of arguments. Expected 1, found: 2 + --> lib.cairo[print_macro]:3:5 + core::result::ResultTrait::<(), core::fmt::Error>::unwrap( + ^********************************************************^ + warning[E0001]: Unused variable. Consider ignoring by prefixing with `_`. --> lib.cairo:2:9 let ba: ByteArray = "hello"; @@ -735,6 +753,9 @@ fn foo() { // Unused arguments. println!("{2}{0}", ba, 2, 1); + + // Missing parens. + println!; } //! > function_name @@ -743,6 +764,11 @@ foo //! > module_code //! > expected_diagnostics +error: Missing tokens. Expected an argument list wrapped in either parentheses, brackets, or braces. + --> lib.cairo:32:13 + println!; + ^ + error: Plugin diagnostic: Macro `writeln` does not support this bracket type. --> lib.cairo:5:13 println!["{}", ba]; @@ -788,6 +814,16 @@ error: Plugin diagnostic: Unused argument. println!("{2}{0}", ba, 2, 1); ^ +error: Plugin diagnostic: Macro `writeln` does not support this bracket type. + --> lib.cairo:32:13 + println!; + ^ + +error: Wrong number of arguments. Expected 1, found: 2 + --> lib.cairo[println_macro]:3:5 + core::result::ResultTrait::<(), core::fmt::Error>::unwrap( + ^********************************************************^ + warning[E0001]: Unused variable. Consider ignoring by prefixing with `_`. --> lib.cairo:2:9 let ba: ByteArray = "hello"; diff --git a/crates/cairo-lang-semantic/src/inline_macros/print.rs b/crates/cairo-lang-semantic/src/inline_macros/print.rs index c57f6995dca..0d539b44024 100644 --- a/crates/cairo-lang-semantic/src/inline_macros/print.rs +++ b/crates/cairo-lang-semantic/src/inline_macros/print.rs @@ -73,7 +73,9 @@ fn generate_code_inner( ), ( "args".to_string(), - RewriteNode::new_trimmed(arguments.arg_list(db).unwrap().as_syntax_node()), + arguments.arg_list(db).map_or_else(RewriteNode::empty, |n| { + RewriteNode::new_trimmed(n.as_syntax_node()) + }), ), ] .into(),