Sitelet https://github.com/starkware-libs/cairo/commit/37d764e013c7955d2a5cb60c8d919a3b50797679
Skip to content

Commit 37d764e

Browse files
authored
bugfix(plugins): Made compile_error! diag not include "s. (#10064)
1 parent 3792f50 commit 37d764e

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎crates/cairo-lang-plugins/src/plugins/compile_error.rs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use cairo_lang_defs::plugin::{MacroPlugin, MacroPluginMetadata, PluginDiagnostic
33
use cairo_lang_defs::plugin_utils::{PluginResultTrait, not_legacy_macro_diagnostic};
44
use cairo_lang_filesystem::ids::SmolStrId;
55
use cairo_lang_parser::macro_helpers::AsLegacyInlineMacro;
6-
use cairo_lang_syntax::node::{Terminal, TypedStablePtr, TypedSyntaxNode, ast};
6+
use cairo_lang_syntax::node::{TypedStablePtr, TypedSyntaxNode, ast};
77
use salsa::Database;
88

99
/// Plugin that allows writing item level `compile_error!` causing a diagnostic.
@@ -38,8 +38,10 @@ impl MacroPlugin for CompileErrorPlugin {
3838
item_ast_ptr
3939
);
4040
PluginResult::diagnostic_only(
41-
if let ast::Expr::String(err_message) = compilation_error_arg {
42-
PluginDiagnostic::error(item_ast_ptr, err_message.text(db).to_string(db))
41+
if let ast::Expr::String(err_message_arg) = &compilation_error_arg
42+
&& let Some(err_message) = err_message_arg.string_value(db)
43+
{
44+
PluginDiagnostic::error(item_ast_ptr, err_message)
4345
} else {
4446
PluginDiagnostic::error_with_inner_span(
4547
db,

‎crates/cairo-lang-plugins/src/test_data/compile_error‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ compile_error!("message", "extra");
3333
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3434

3535

36-
error: "error message"
36+
error: error message
3737
--> test_src/lib.cairo:7:1
3838
compile_error!("error message");
3939
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -58,7 +58,7 @@ compile_error!("ignore");
5858
//! > expanded_cairo_code
5959

6060
//! > expected_diagnostics
61-
error: "show"
61+
error: show
6262
--> test_src/lib.cairo:1:1-2:23
6363
#[cfg(noignore)]
6464
_^

0 commit comments

Comments
 (0)