File tree Expand file tree Collapse file tree
crates/cairo-lang-semantic/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2698,3 +2698,35 @@ error[E2200]: Plugin diagnostic: Literals with suffix are not supported in const
26982698 --> lib.cairo:1:35
26992699const a: felt252 = consteval_int!(1_u32 + 2);
27002700 ^^^^^^
2701+
2702+ //! > ==========================================================================
2703+
2704+ //! > Regression for #9936: unsupported macro param kind emits a diagnostic, not an ICE.
2705+
2706+ //! > test_runner_name
2707+ test_function_diagnostics(expect_diagnostics: true)
2708+
2709+ //! > function_code
2710+ fn foo() -> u32 {
2711+ mymac!(0)
2712+ }
2713+
2714+ //! > function_name
2715+ foo
2716+
2717+ //! > module_code
2718+ #[feature("user_defined_inline_macros")]
2719+ macro mymac {
2720+ ($x:literal) => { 5_u32 };
2721+ }
2722+
2723+ //! > expected_diagnostics
2724+ error[E1008]: Missing tokens. Expected a macro rule parameter kind.
2725+ --> lib.cairo:3:9
2726+ ($x:literal) => { 5_u32 };
2727+ ^
2728+
2729+ error[E2158]: No matching rule found in inline macro `mymac`.
2730+ --> lib.cairo:6:5
2731+ mymac!(0)
2732+ ^^^^^^^^^
Original file line number Diff line number Diff line change @@ -156,6 +156,10 @@ fn priv_macro_declaration_data<'db>(
156156 rule_err : Ok ( ( ) ) ,
157157 } ;
158158 ctx. check_node ( expansion. as_syntax_node ( ) ) ;
159+ // Skipping expanding an inline macro if it had a parser error.
160+ if pattern. as_syntax_node ( ) . descendants ( db) . any ( |node| node. kind ( db) . is_missing ( ) ) {
161+ continue ;
162+ }
159163 rules. push ( MacroRuleData { pattern, expansion, err : ctx. rule_err } ) ;
160164 }
161165 let resolver_data = Arc :: new ( resolver. data ) ;
@@ -376,12 +380,10 @@ fn is_macro_rule_match_ex<'db>(
376380 }
377381 ast:: MacroElement :: Param ( param) => {
378382 advanced = true ;
379- let placeholder_kind: PlaceholderKind =
380- if let ast:: OptionParamKind :: ParamKind ( param_kind) = param. kind ( db) {
381- param_kind. kind ( db) . into ( )
382- } else {
383- return None ;
384- } ;
383+ let ast:: OptionParamKind :: ParamKind ( param_kind) = param. kind ( db) else {
384+ return None ;
385+ } ;
386+ let placeholder_kind: PlaceholderKind = param_kind. kind ( db) . into ( ) ;
385387 let placeholder_name = param. name ( db) . as_syntax_node ( ) . get_text_without_trivia ( db) ;
386388 match placeholder_kind {
387389 PlaceholderKind :: Identifier => {
You can’t perform that action at this time.
0 commit comments