Ver Fonte

zkas/analyzer: Improve incorrect argument error messages.

parazyd há 4 anos atrás
pai
commit
5dbf0ac421
1 ficheiros alterados com 14 adições e 6 exclusões
  1. 14 6
      zkas/src/analyzer.rs

+ 14 - 6
zkas/src/analyzer.rs

@@ -67,7 +67,11 @@ impl Analyzer {
                                 };
                                 if var_type != Type::Base {
                                     self.error(
-                                        "Incorrect argument type. Expected `Base`.".to_string(),
+                                        format!(
+                                            "Incorrect argument type. Expected `{:?}`, got `{:?}`",
+                                            Type::Base,
+                                            var_type
+                                        ),
                                         i.line,
                                         i.column,
                                     );
@@ -96,8 +100,8 @@ impl Analyzer {
                                 if var_type != arg_types[idx] {
                                     self.error(
                                         format!(
-                                            "Incorrect argument type. Expected `{:?}`.",
-                                            arg_types[idx]
+                                            "Incorrect argument type. Expected `{:?}`, got `{:?}`",
+                                            arg_types[idx], var_type,
                                         ),
                                         i.line,
                                         i.column,
@@ -143,7 +147,11 @@ impl Analyzer {
                                 };
                                 if var_type != Type::Base {
                                     self.error(
-                                        "Incorrect argument type. Expected `Base`.".to_string(),
+                                        format!(
+                                            "Incorrect argument type. Expected `{:?}`, got `{:?}`",
+                                            Type::Base,
+                                            var_type
+                                        ),
                                         i.line,
                                         i.column,
                                     );
@@ -172,8 +180,8 @@ impl Analyzer {
                                 if var_type != arg_types[idx] {
                                     self.error(
                                         format!(
-                                            "Incorrect argument type. Expected `{:?}`.",
-                                            arg_types[idx]
+                                            "Incorrect argument type. Expected `{:?}`, got `{:?}`",
+                                            arg_types[idx], var_type,
                                         ),
                                         i.line,
                                         i.column,