Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions crates/cairo-lang-semantic/src/expr/test_data/statements
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,35 @@ fn unstable_function_with_note() -> felt252 {
//! > function_body

//! > expected_diagnostics

//! > ==========================================================================

//! > Declarative macro with parameter missing kind specifier.

//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)

//! > function_code
fn foo() {
m!(1);
}

//! > function_name
foo

//! > module_code
macro m {
($x) => { 0 };
}

//! > expected_diagnostics
error[E1010]: Macro parameter must have a kind.
--> lib.cairo:2:7
($x) => { 0 };
^

error[E2158]: No matching rule found in inline macro `m`.
--> lib.cairo:5:5
m!(1);
^^^^^

5 changes: 1 addition & 4 deletions crates/cairo-lang-semantic/src/items/macro_declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,7 @@ fn is_macro_rule_match_ex<'db>(
if let ast::OptionParamKind::ParamKind(param_kind) = param.kind(db) {
param_kind.kind(db).into()
} else {
unreachable!(
"Missing macro rule param kind, should have been handled by the \
parser."
)
return None;
};
let placeholder_name = param.name(db).as_syntax_node().get_text_without_trivia(db);
match placeholder_kind {
Expand Down
Loading