Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made inline macro plugins point to the inner syntax. #4345

Merged
merged 1 commit into from
Nov 2, 2023
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
2 changes: 1 addition & 1 deletion crates/cairo-lang-semantic/src/expr/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ fn compute_expr_inline_macro_semantic(

let result = macro_plugin.generate_code(syntax_db, syntax);
for diagnostic in result.diagnostics {
ctx.diagnostics.report(syntax, PluginDiagnostic(diagnostic));
ctx.diagnostics.report_by_ptr(diagnostic.stable_ptr, PluginDiagnostic(diagnostic));
}

let Some(code) = result.code else {
Expand Down
44 changes: 22 additions & 22 deletions crates/cairo-lang-semantic/src/expr/test_data/inline_macros
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const e: felt252 = consteval_int![4 + 5];
^

error: Plugin diagnostic: Unsupported expression in consteval_int macro
--> lib.cairo:1:20
--> lib.cairo:1:35
const a: felt252 = consteval_int!(func_call(24));
^***************************^
^***********^

error: Inline macro `consteval_int` failed.
--> lib.cairo:1:20
Expand All @@ -48,9 +48,9 @@ const a: felt252 = consteval_int!(func_call(24));
^***************************^

error: Plugin diagnostic: Unsupported expression in consteval_int macro
--> lib.cairo:3:20
--> lib.cairo:3:35
const b: felt252 = consteval_int!('some string');
^***************************^
^***********^

error: Inline macro `consteval_int` failed.
--> lib.cairo:3:20
Expand All @@ -63,9 +63,9 @@ const b: felt252 = consteval_int!('some string');
^***************************^

error: Plugin diagnostic: Unsupported unary operator in consteval_int macro
--> lib.cairo:5:20
--> lib.cairo:5:35
const c: felt252 = consteval_int!(*24);
^*****************^
^*^

error: Inline macro `consteval_int` failed.
--> lib.cairo:5:20
Expand All @@ -78,9 +78,9 @@ const c: felt252 = consteval_int!(*24);
^*****************^

error: Plugin diagnostic: Unsupported unary operator in consteval_int macro
--> lib.cairo:7:20
--> lib.cairo:7:35
const d: felt252 = consteval_int!(~24);
^*****************^
^*^

error: Inline macro `consteval_int` failed.
--> lib.cairo:7:20
Expand All @@ -93,9 +93,9 @@ const d: felt252 = consteval_int!(~24);
^*****************^

error: Plugin diagnostic: Unsupported binary operator in consteval_int macro
--> lib.cairo:9:20
--> lib.cairo:9:35
const e: felt252 = consteval_int!(234 < 5);
^*********************^
^*****^

error: Inline macro `consteval_int` failed.
--> lib.cairo:9:20
Expand All @@ -108,9 +108,9 @@ const e: felt252 = consteval_int!(234 < 5);
^*********************^

error: Plugin diagnostic: Macro `consteval_int` does not support this bracket type.
--> lib.cairo:11:20
--> lib.cairo:11:34
const e: felt252 = consteval_int![4 + 5];
^*******************^
^

error: Inline macro `consteval_int` failed.
--> lib.cairo:11:20
Expand All @@ -123,9 +123,9 @@ const e: felt252 = consteval_int![4 + 5];
^*******************^

error: Plugin diagnostic: Macro `consteval_int` does not support this bracket type.
--> lib.cairo:13:20
--> lib.cairo:13:34
const f: felt252 = consteval_int!{4 + 5};
^*******************^
^

error: Inline macro `consteval_int` failed.
--> lib.cairo:13:20
Expand Down Expand Up @@ -162,9 +162,9 @@ foo

//! > expected_diagnostics
error: Plugin diagnostic: Macro `array` does not support this bracket type.
--> lib.cairo:2:13
--> lib.cairo:2:19
let x = array!(0);
^*******^
^

error: Inline macro `array` failed.
--> lib.cairo:2:13
Expand Down Expand Up @@ -207,9 +207,9 @@ foo

//! > expected_diagnostics
error: Plugin diagnostic: Macro `format` does not support this bracket type.
--> lib.cairo:5:4
--> lib.cairo:5:11
format!["{}", ba];
^***************^
^

error: Inline macro `format` failed.
--> lib.cairo:5:4
Expand Down Expand Up @@ -277,9 +277,9 @@ foo

//! > expected_diagnostics
error: Plugin diagnostic: Macro `print` does not support this bracket type.
--> lib.cairo:5:4
--> lib.cairo:5:10
print!["{}", ba];
^**************^
^

error: Inline macro `print` failed.
--> lib.cairo:5:4
Expand Down Expand Up @@ -347,9 +347,9 @@ foo

//! > expected_diagnostics
error: Plugin diagnostic: Macro `println` does not support this bracket type.
--> lib.cairo:5:4
--> lib.cairo:5:12
println!["{}", ba];
^****************^
^

error: Inline macro `println` failed.
--> lib.cairo:5:4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6374,9 +6374,9 @@ mod component3 {

//! > expected_diagnostics
error: Plugin diagnostic: The first argument of `get_dep_component_mut` macro must have only a `ref` modifier.
--> lib.cairo:53:13
--> lib.cairo:53:36
get_dep_component_mut!(Comp1, self).foo1();
^*********************************^
^***^

error: Inline macro `get_dep_component_mut` failed.
--> lib.cairo:53:13
Expand Down Expand Up @@ -6404,39 +6404,39 @@ error: Method `foo1` not found on type "test::component2::ComponentState::<TCont
^**^

error: Plugin diagnostic: The first argument of `get_dep_component_mut` macro must have only a `ref` modifier.
--> lib.cairo:57:13
--> lib.cairo:57:36
get_dep_component_mut!(self, Comp1).foo1();
^*********************************^
^**^

error: Inline macro `get_dep_component_mut` failed.
--> lib.cairo:57:13
get_dep_component_mut!(self, Comp1).foo1();
^*********************************^

error: Plugin diagnostic: The first argument of `get_dep_component_mut` macro must have only a `ref` modifier.
--> lib.cairo:58:13
--> lib.cairo:58:40
get_dep_component_mut!(mut self, Comp1).foo1();
^*************************************^
^**^

error: Inline macro `get_dep_component_mut` failed.
--> lib.cairo:58:13
get_dep_component_mut!(mut self, Comp1).foo1();
^*************************************^

error: Plugin diagnostic: The first argument of `get_dep_component_mut` macro must have only a `ref` modifier.
--> lib.cairo:59:13
--> lib.cairo:59:44
get_dep_component_mut!(ref ref self, Comp1).foo1();
^*****************************************^
^**^

error: Inline macro `get_dep_component_mut` failed.
--> lib.cairo:59:13
get_dep_component_mut!(ref ref self, Comp1).foo1();
^*****************************************^

error: Plugin diagnostic: The first argument of `get_dep_component_mut` macro must have only a `ref` modifier.
--> lib.cairo:60:13
--> lib.cairo:60:44
get_dep_component_mut!(ref mut self, Comp1).foo1();
^*****************************************^
^**^

error: Inline macro `get_dep_component_mut` failed.
--> lib.cairo:60:13
Expand Down