diff --git a/crates/analyzer/src/context.rs b/crates/analyzer/src/context.rs index c9ae5c74e8..fa6e3c5ef7 100644 --- a/crates/analyzer/src/context.rs +++ b/crates/analyzer/src/context.rs @@ -374,10 +374,6 @@ pub struct FunctionBody { pub string_literals: IndexSet, // for yulgen // Map lhs of variable declaration to type. pub var_types: IndexMap, - - // This is the id of the VarDecl TypeDesc node - // TODO: Do we really need this? - pub var_decl_types: IndexMap, pub calls: IndexMap, pub spans: HashMap, } diff --git a/crates/analyzer/src/db/queries/functions.rs b/crates/analyzer/src/db/queries/functions.rs index 86a2e85449..0facf832a4 100644 --- a/crates/analyzer/src/db/queries/functions.rs +++ b/crates/analyzer/src/db/queries/functions.rs @@ -356,7 +356,7 @@ pub fn function_dependency_graph(db: &dyn AnalyzerDb, function: FunctionId) -> D .values() .map(|event| (root, Item::Event(*event), DepLocality::Local)), ); - directs.extend(body.var_decl_types.values().filter_map(|typ| match typ { + directs.extend(body.var_types.values().filter_map(|typ| match typ { Type::Contract(Contract { id, .. }) => Some(( root, Item::Type(TypeDef::Contract(*id)), diff --git a/crates/analyzer/src/db/queries/ingots.rs b/crates/analyzer/src/db/queries/ingots.rs index e6a0b08cd0..8cc6abf6a4 100644 --- a/crates/analyzer/src/db/queries/ingots.rs +++ b/crates/analyzer/src/db/queries/ingots.rs @@ -39,7 +39,7 @@ pub fn ingot_modules(db: &dyn AnalyzerDb, ingot: IngotId) -> Rc<[ModuleId]> { .iter() .flat_map(|(_file, path)| { path.strip_prefix(&file_path_prefix.as_str()) - .unwrap_or_else(|_| path) + .unwrap_or(path) .ancestors() .skip(1) // first elem of .ancestors() is the path itself }) @@ -52,7 +52,7 @@ pub fn ingot_modules(db: &dyn AnalyzerDb, ingot: IngotId) -> Rc<[ModuleId]> { .iter() .map(|(_file, path)| { path.strip_prefix(&file_path_prefix.as_str()) - .unwrap_or_else(|_| path) + .unwrap_or(path) .as_str() .trim_end_matches(".fe") .into() diff --git a/crates/analyzer/src/errors.rs b/crates/analyzer/src/errors.rs index 1804c1273a..1e956e572e 100644 --- a/crates/analyzer/src/errors.rs +++ b/crates/analyzer/src/errors.rs @@ -124,10 +124,6 @@ pub struct AlreadyDefined; #[derive(Debug)] pub struct CannotMove; -/// Error indicating that a [`Type`] does not have a fixed size. -#[derive(Debug)] -pub struct NotFixedSize; - /// Errors that can result from indexing #[derive(Debug, PartialEq)] pub enum IndexingError { @@ -145,9 +141,6 @@ pub enum BinaryOperationError { NotEqualAndUnsigned, } -#[derive(Debug)] -pub struct AnalyzerError(pub Vec); - impl From for FatalError { fn from(err: TypeError) -> Self { Self::new(err.0) diff --git a/crates/analyzer/src/namespace/items.rs b/crates/analyzer/src/namespace/items.rs index 277a57ab93..b1f25bcc87 100644 --- a/crates/analyzer/src/namespace/items.rs +++ b/crates/analyzer/src/namespace/items.rs @@ -214,14 +214,6 @@ impl Item { } } - /// Downcast utility function - pub fn as_contract(&self) -> Option { - match self { - Item::Type(TypeDef::Contract(id)) => Some(*id), - _ => None, - } - } - pub fn sink_diagnostics(&self, db: &dyn AnalyzerDb, sink: &mut impl DiagnosticSink) { match self { Item::Type(id) => id.sink_diagnostics(db, sink), @@ -641,11 +633,6 @@ impl ModuleId { items } - /// All structs, including duplicatecrates/analyzer/src/db.rss - pub fn all_structs(&self, db: &dyn AnalyzerDb) -> Rc<[StructId]> { - db.module_structs(*self) - } - /// All module constants. pub fn all_constants(&self, db: &dyn AnalyzerDb) -> Rc> { db.module_constants(*self) @@ -978,11 +965,6 @@ impl ContractId { db.contract_public_function_map(*self) } - /// Get a function that takes self by its name. - pub fn self_function(&self, db: &dyn AnalyzerDb, name: &str) -> Option { - self.function(db, name).filter(|f| f.takes_self(db)) - } - /// Lookup an event by name. pub fn event(&self, db: &dyn AnalyzerDb, name: &str) -> Option { self.events(db).get(name).copied() @@ -1196,12 +1178,6 @@ impl Class { } } -#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] -pub enum MemberFunction { - BuiltIn(builtins::ValueMethod), - Function(FunctionId), -} - #[derive(Debug, PartialEq, Eq, Hash, Clone)] pub struct Struct { pub ast: Node, @@ -1256,10 +1232,6 @@ impl StructId { matches!(self.field_type(db, name), Some(Ok(types::Type::Base(_)))) } - pub fn field_index(&self, db: &dyn AnalyzerDb, name: &str) -> Option { - self.fields(db).get_index_of(name) - } - pub fn has_complex_fields(&self, db: &dyn AnalyzerDb) -> bool { self.fields(db) .iter() @@ -1280,9 +1252,6 @@ impl StructId { pub fn function(&self, db: &dyn AnalyzerDb, name: &str) -> Option { self.functions(db).get(name).copied() } - pub fn self_function(&self, db: &dyn AnalyzerDb, name: &str) -> Option { - self.function(db, name).filter(|f| f.takes_self(db)) - } pub fn parent(&self, db: &dyn AnalyzerDb) -> Item { Item::Module(self.data(db).module) } diff --git a/crates/analyzer/src/namespace/scopes.rs b/crates/analyzer/src/namespace/scopes.rs index 2b593fbeff..48f03ece9c 100644 --- a/crates/analyzer/src/namespace/scopes.rs +++ b/crates/analyzer/src/namespace/scopes.rs @@ -188,20 +188,6 @@ impl<'a> FunctionScope<'a> { .expect_none("emit statement attributes already exist"); } - /// Attribute contextual information to a declaration node. - /// - /// # Panics - /// - /// Panics if an entry already exists for the node id. - pub fn add_declaration(&self, node: &Node, typ: Type) { - self.add_node(node); - self.body - .borrow_mut() - .var_decl_types - .insert(node.id, typ) - .expect_none("declaration attributes already exist"); - } - pub fn map_variable_type(&self, node: &Node, typ: Type) { self.add_node(node); self.body diff --git a/crates/analyzer/src/namespace/types.rs b/crates/analyzer/src/namespace/types.rs index 050db6e422..a5ce40670c 100644 --- a/crates/analyzer/src/namespace/types.rs +++ b/crates/analyzer/src/namespace/types.rs @@ -380,21 +380,6 @@ pub struct EventField { } impl FunctionSignature { - /// # Panics - /// Panics if any param type is an `Err` - pub fn param_types(&self) -> Vec { - self.params - .iter() - .map(|param| param.typ.clone().expect("fn param type error")) - .collect() - } - - /// # Panics - /// Panics if the return type is an `Err` - pub fn expect_return_type(&self) -> Type { - self.return_type.clone().expect("fn return type error") - } - /// Parameters without `ctx`, if it is a contract function that declares it. /// /// This is used when calling a contract method externally. @@ -491,21 +476,6 @@ impl Type { Type::Base(Base::Numeric(int_type)) } - pub fn generic_arg_type(&self, idx: usize) -> Option { - match self { - Type::Map(Map { key, value }) => match idx { - 0 => Some(Type::Base(*key)), - 1 => Some((**value).clone()), - _ => None, - }, - Type::Array(array) => match idx { - 0 => Some(Type::Base(array.inner)), - _ => None, - }, - _ => None, - } - } - pub fn has_fixed_size(&self) -> bool { match self { Type::Base(_) diff --git a/crates/analyzer/src/traversal/declarations.rs b/crates/analyzer/src/traversal/declarations.rs index 880165091f..32d1495be4 100644 --- a/crates/analyzer/src/traversal/declarations.rs +++ b/crates/analyzer/src/traversal/declarations.rs @@ -33,7 +33,6 @@ pub fn var_decl(scope: &mut BlockScope, stmt: &Node) -> Result<(), } } - scope.root.add_declaration(typ, declared_type.clone()); add_var(scope, target, declared_type)?; return Ok(()); } @@ -70,7 +69,6 @@ pub fn const_decl(scope: &mut BlockScope, stmt: &Node) -> Result<( // Perform constant evaluation. let const_value = const_expr::eval_expr(scope, value)?; - scope.root.add_declaration(typ, declared_type.clone()); scope.root.map_variable_type(name, declared_type.clone()); // this logs a message on err, so it's safe to ignore here. let _ = scope.add_var(name.kind.as_str(), declared_type, true, name.span); diff --git a/crates/analyzer/tests/analysis.rs b/crates/analyzer/tests/analysis.rs index 81a16a2f6d..42df1684aa 100644 --- a/crates/analyzer/tests/analysis.rs +++ b/crates/analyzer/tests/analysis.rs @@ -416,7 +416,7 @@ fn function_diagnostics(fun: items::FunctionId, db: &dyn AnalyzerDb) -> Vec - │ ^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^ Array note: ┌─ aug_assign.fe:67:9 diff --git a/crates/analyzer/tests/snapshots/analysis__basic_ingot.snap b/crates/analyzer/tests/snapshots/analysis__basic_ingot.snap index 759256df5f..dcf603af5d 100644 --- a/crates/analyzer/tests/snapshots/analysis__basic_ingot.snap +++ b/crates/analyzer/tests/snapshots/analysis__basic_ingot.snap @@ -281,10 +281,10 @@ note: } note: - ┌─ ingots/basic_ingot/src/main.fe:37:28 + ┌─ ingots/basic_ingot/src/main.fe:37:13 │ 37 │ let bing_contract: BingContract = BingContract.create(ctx, 0) - │ ^^^^^^^^^^^^ BingContract + │ ^^^^^^^^^^^^^ BingContract note: ┌─ ingots/basic_ingot/src/main.fe:37:63 diff --git a/crates/analyzer/tests/snapshots/analysis__const_generics.snap b/crates/analyzer/tests/snapshots/analysis__const_generics.snap index 6ba16ef208..307ebb0682 100644 --- a/crates/analyzer/tests/snapshots/analysis__const_generics.snap +++ b/crates/analyzer/tests/snapshots/analysis__const_generics.snap @@ -27,75 +27,75 @@ note: } note: - ┌─ const_generics.fe:4:24 + ┌─ const_generics.fe:4:13 │ 4 │ let array_lit: Array - │ ^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 5 │ let array_lit2: Array - │ ^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^^ Array · 8 │ let array_ternary: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^^^^^ Array · 11 │ let array_logical_or: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^^^^^^^^ Array 12 │ let array_logical_and: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^^^^^^^^^ Array · 15 │ let array_add: Array - │ ^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 16 │ let array_sub: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 17 │ let array_mul: Array - │ ^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 18 │ let array_div: Array - │ ^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 19 │ let array_mod: Array - │ ^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 20 │ let array_pow: Array - │ ^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 21 │ let array_shl: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 22 │ let array_shr: Array> 2 }> - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 23 │ let array_bitor: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^^^ Array 24 │ let array_xor: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 25 │ let array_bitand: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^^^^ Array · 28 │ let array_eq: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^ Array 29 │ let array_ne: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^ Array 30 │ let array_lt1: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 31 │ let array_lt2: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 32 │ let array_lte: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 33 │ let array_lte2: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^^ Array 34 │ let array_gt: Array 0 else 0 }> - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^ Array 35 │ let array_gt2: Array 10 else 8 }> - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 36 │ let array_gte: Array= 10 else 8 }> - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array 37 │ let array_gte2: Array= 10 else 0 }> - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^^ Array · 40 │ let array_not: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^ Array · 43 │ const DOUBLE_ARRAY_LENGTH: u64 = 16 - │ ^^^ u64 + │ ^^^^^^^^^^^^^^^^^^^ u64 44 │ const TWO: u64 = 2 - │ ^^^ u64 + │ ^^^ u64 45 │ 46 │ let array_with_const: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^^^^^^^^ Array note: ┌─ const_generics.fe:5:38 diff --git a/crates/analyzer/tests/snapshots/analysis__const_local.snap b/crates/analyzer/tests/snapshots/analysis__const_local.snap index dd7bce88e7..91092f8ae3 100644 --- a/crates/analyzer/tests/snapshots/analysis__const_local.snap +++ b/crates/analyzer/tests/snapshots/analysis__const_local.snap @@ -29,32 +29,32 @@ note: } note: - ┌─ const_local.fe:3:19 + ┌─ const_local.fe:3:15 │ 3 │ const C1: i64 = 1 - │ ^^^ i64 + │ ^^ i64 4 │ const C2: i64 = 2 - │ ^^^ i64 + │ ^^ i64 5 │ const C3: i64 = 10 - │ ^^^ i64 + │ ^^ i64 6 │ const C4: i64 = (C1 * C2) + C3 # 12 - │ ^^^ i64 + │ ^^ i64 7 │ const EXP: u8 = 2 - │ ^^ u8 + │ ^^^ u8 8 │ const C5: i64 = (C2 ** EXP) # 4 - │ ^^^ i64 + │ ^^ i64 9 │ const C6: i64 = (C5 << 1) # 8 - │ ^^^ i64 + │ ^^ i64 10 │ const C7: bool = (C5 < C6) and (C4 > C5) # true - │ ^^^^ bool + │ ^^ bool 11 │ const C8: bool = false - │ ^^^^ bool + │ ^^ bool 12 │ const C9: bool = C8 < C7 # true - │ ^^^^ bool + │ ^^ bool 13 │ const C10: u256 = 42 if C9 else 0 # 42 - │ ^^^^ u256 + │ ^^^ u256 14 │ let _arr: Array - │ ^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^ Array note: ┌─ const_local.fe:3:25 diff --git a/crates/analyzer/tests/snapshots/analysis__create2_contract.snap b/crates/analyzer/tests/snapshots/analysis__create2_contract.snap index 3ffbafc8d3..4f6af3b543 100644 --- a/crates/analyzer/tests/snapshots/analysis__create2_contract.snap +++ b/crates/analyzer/tests/snapshots/analysis__create2_contract.snap @@ -66,10 +66,10 @@ note: } note: - ┌─ create2_contract.fe:11:18 + ┌─ create2_contract.fe:11:13 │ 11 │ let foo: Foo = Foo.create2(ctx, 0, 52) - │ ^^^ Foo + │ ^^^ Foo note: ┌─ create2_contract.fe:11:36 diff --git a/crates/analyzer/tests/snapshots/analysis__create_contract.snap b/crates/analyzer/tests/snapshots/analysis__create_contract.snap index 6e242395fe..993a0a5fbb 100644 --- a/crates/analyzer/tests/snapshots/analysis__create_contract.snap +++ b/crates/analyzer/tests/snapshots/analysis__create_contract.snap @@ -66,10 +66,10 @@ note: } note: - ┌─ create_contract.fe:11:18 + ┌─ create_contract.fe:11:13 │ 11 │ let foo: Foo = Foo.create(ctx, 0) - │ ^^^ Foo + │ ^^^ Foo note: ┌─ create_contract.fe:11:35 diff --git a/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap b/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap index 1b4d6cdcdf..a697430005 100644 --- a/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap +++ b/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap @@ -237,12 +237,12 @@ note: } note: - ┌─ data_copying_stress.fe:29:27 + ┌─ data_copying_stress.fe:29:13 │ 29 │ let my_2nd_array: Array = my_array - │ ^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^^^^ Array 30 │ let my_3rd_array: Array = my_2nd_array - │ ^^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^^^^ Array note: ┌─ data_copying_stress.fe:29:45 @@ -606,10 +606,10 @@ note: } note: - ┌─ data_copying_stress.fe:57:26 + ┌─ data_copying_stress.fe:57:13 │ 57 │ let my_nums_mem: Array - │ ^^^^^^^^^^^^^^ Array + │ ^^^^^^^^^^^ Array note: ┌─ data_copying_stress.fe:58:9 diff --git a/crates/analyzer/tests/snapshots/analysis__events.snap b/crates/analyzer/tests/snapshots/analysis__events.snap index b8b4b0633d..6dad34fe82 100644 --- a/crates/analyzer/tests/snapshots/analysis__events.snap +++ b/crates/analyzer/tests/snapshots/analysis__events.snap @@ -379,10 +379,10 @@ note: } note: - ┌─ events.fe:38:20 + ┌─ events.fe:38:13 │ 38 │ let addrs: Array - │ ^^^^^^^^^^^^^^^^^ Array + │ ^^^^^ Array note: ┌─ events.fe:39:9 diff --git a/crates/analyzer/tests/snapshots/analysis__external_contract.snap b/crates/analyzer/tests/snapshots/analysis__external_contract.snap index 10037f97cc..0e576c838f 100644 --- a/crates/analyzer/tests/snapshots/analysis__external_contract.snap +++ b/crates/analyzer/tests/snapshots/analysis__external_contract.snap @@ -189,10 +189,10 @@ note: } note: - ┌─ external_contract.fe:15:23 + ┌─ external_contract.fe:15:13 │ 15 │ let my_array: Array - │ ^^^^^^^^^^^^^^ Array + │ ^^^^^^^^ Array note: ┌─ external_contract.fe:16:9 @@ -322,10 +322,10 @@ note: } note: - ┌─ external_contract.fe:25:18 + ┌─ external_contract.fe:25:13 │ 25 │ let foo: Foo = Foo(ctx, foo_address) - │ ^^^ Foo + │ ^^^ Foo note: ┌─ external_contract.fe:25:28 @@ -425,10 +425,10 @@ note: } note: - ┌─ external_contract.fe:30:18 + ┌─ external_contract.fe:30:13 │ 30 │ let foo: Foo = Foo(ctx, foo_address) - │ ^^^ Foo + │ ^^^ Foo note: ┌─ external_contract.fe:30:28 diff --git a/crates/analyzer/tests/snapshots/analysis__for_loop_with_break.snap b/crates/analyzer/tests/snapshots/analysis__for_loop_with_break.snap index 56783e6d60..9591dcffbf 100644 --- a/crates/analyzer/tests/snapshots/analysis__for_loop_with_break.snap +++ b/crates/analyzer/tests/snapshots/analysis__for_loop_with_break.snap @@ -29,13 +29,15 @@ note: } note: - ┌─ for_loop_with_break.fe:3:23 + ┌─ for_loop_with_break.fe:3:13 │ 3 │ let my_array: Array - │ ^^^^^^^^^^^^^^ Array + │ ^^^^^^^^ Array · 7 │ let sum: u256 = 0 - │ ^^^^ u256 + │ ^^^ u256 +8 │ for i in my_array { + │ ^ u256 note: ┌─ for_loop_with_break.fe:4:9 diff --git a/crates/analyzer/tests/snapshots/analysis__for_loop_with_continue.snap b/crates/analyzer/tests/snapshots/analysis__for_loop_with_continue.snap index 35eb020247..c33ca380d0 100644 --- a/crates/analyzer/tests/snapshots/analysis__for_loop_with_continue.snap +++ b/crates/analyzer/tests/snapshots/analysis__for_loop_with_continue.snap @@ -29,13 +29,15 @@ note: } note: - ┌─ for_loop_with_continue.fe:3:23 - │ -3 │ let my_array: Array - │ ^^^^^^^^^^^^^^ Array - · -9 │ let sum: u256 = 0 - │ ^^^^ u256 + ┌─ for_loop_with_continue.fe:3:13 + │ + 3 │ let my_array: Array + │ ^^^^^^^^ Array + · + 9 │ let sum: u256 = 0 + │ ^^^ u256 +10 │ for i in my_array { + │ ^ u256 note: ┌─ for_loop_with_continue.fe:4:9 diff --git a/crates/analyzer/tests/snapshots/analysis__for_loop_with_static_array.snap b/crates/analyzer/tests/snapshots/analysis__for_loop_with_static_array.snap index e7618187d7..db1bd5e526 100644 --- a/crates/analyzer/tests/snapshots/analysis__for_loop_with_static_array.snap +++ b/crates/analyzer/tests/snapshots/analysis__for_loop_with_static_array.snap @@ -29,13 +29,15 @@ note: } note: - ┌─ for_loop_with_static_array.fe:3:23 + ┌─ for_loop_with_static_array.fe:3:13 │ 3 │ let my_array: Array - │ ^^^^^^^^^^^^^^ Array + │ ^^^^^^^^ Array · 7 │ let sum: u256 = 0 - │ ^^^^ u256 + │ ^^^ u256 +8 │ for i in my_array { + │ ^ u256 note: ┌─ for_loop_with_static_array.fe:4:9 diff --git a/crates/analyzer/tests/snapshots/analysis__if_statement_with_block_declaration.snap b/crates/analyzer/tests/snapshots/analysis__if_statement_with_block_declaration.snap index ed62510981..eb13632a72 100644 --- a/crates/analyzer/tests/snapshots/analysis__if_statement_with_block_declaration.snap +++ b/crates/analyzer/tests/snapshots/analysis__if_statement_with_block_declaration.snap @@ -29,13 +29,13 @@ note: } note: - ┌─ if_statement_with_block_declaration.fe:4:20 + ┌─ if_statement_with_block_declaration.fe:4:17 │ 4 │ let y: u256 = 1 - │ ^^^^ u256 + │ ^ u256 · 7 │ let y: u256 = 1 - │ ^^^^ u256 + │ ^ u256 note: ┌─ if_statement_with_block_declaration.fe:3:12 diff --git a/crates/analyzer/tests/snapshots/analysis__math.snap b/crates/analyzer/tests/snapshots/analysis__math.snap index 85a771acf5..e8bd4e9d95 100644 --- a/crates/analyzer/tests/snapshots/analysis__math.snap +++ b/crates/analyzer/tests/snapshots/analysis__math.snap @@ -41,13 +41,13 @@ note: } note: - ┌─ math.fe:3:16 + ┌─ math.fe:3:13 │ 3 │ let z: u256 - │ ^^^^ u256 + │ ^ u256 · 6 │ let x: u256 = val / 2 + 1 - │ ^^^^ u256 + │ ^ u256 note: ┌─ math.fe:4:12 diff --git a/crates/analyzer/tests/snapshots/analysis__module_const.snap b/crates/analyzer/tests/snapshots/analysis__module_const.snap index a499742650..1611b3b793 100644 --- a/crates/analyzer/tests/snapshots/analysis__module_const.snap +++ b/crates/analyzer/tests/snapshots/analysis__module_const.snap @@ -59,16 +59,16 @@ note: } note: - ┌─ module_const.fe:10:28 + ┌─ module_const.fe:10:15 │ 10 │ const LOCAL_CONST: i32 = C3 * 2 - │ ^^^ i32 + │ ^^^^^^^^^^^ i32 11 │ let _arr1: Array - │ ^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^ Array 12 │ let _arr2: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + │ ^^^^^ Array 13 │ let _my_array: MY_ARRAY - │ ^^^^^^^^ Array + │ ^^^^^^^^^ Array note: ┌─ module_const.fe:10:34 diff --git a/crates/analyzer/tests/snapshots/analysis__multi_param.snap b/crates/analyzer/tests/snapshots/analysis__multi_param.snap index a36902db78..286088adfd 100644 --- a/crates/analyzer/tests/snapshots/analysis__multi_param.snap +++ b/crates/analyzer/tests/snapshots/analysis__multi_param.snap @@ -66,10 +66,10 @@ note: } note: - ┌─ multi_param.fe:3:23 + ┌─ multi_param.fe:3:13 │ 3 │ let my_array: Array - │ ^^^^^^^^^^^^^^ Array + │ ^^^^^^^^ Array note: ┌─ multi_param.fe:4:9 diff --git a/crates/analyzer/tests/snapshots/analysis__pure_fn_standalone.snap b/crates/analyzer/tests/snapshots/analysis__pure_fn_standalone.snap index 9aaae04129..e5b56bae9d 100644 --- a/crates/analyzer/tests/snapshots/analysis__pure_fn_standalone.snap +++ b/crates/analyzer/tests/snapshots/analysis__pure_fn_standalone.snap @@ -215,10 +215,10 @@ note: } note: - ┌─ pure_fn_standalone.fe:18:16 + ┌─ pure_fn_standalone.fe:18:13 │ 18 │ let a: address = address(x) - │ ^^^^^^^ address + │ ^ address note: ┌─ pure_fn_standalone.fe:18:34 diff --git a/crates/analyzer/tests/snapshots/analysis__return_array.snap b/crates/analyzer/tests/snapshots/analysis__return_array.snap index 116f206e1b..e5bb07533e 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_array.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_array.snap @@ -42,10 +42,10 @@ note: } note: - ┌─ return_array.fe:3:23 + ┌─ return_array.fe:3:13 │ 3 │ let my_array: Array - │ ^^^^^^^^^^^^^^ Array + │ ^^^^^^^^ Array note: ┌─ return_array.fe:4:9 diff --git a/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap b/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap index d324eb003c..30907fe501 100644 --- a/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap +++ b/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap @@ -321,10 +321,10 @@ note: } note: - ┌─ simple_open_auction.fe:59:21 + ┌─ simple_open_auction.fe:59:13 │ 59 │ let amount: u256 = self.pending_returns[ctx.msg_sender()] - │ ^^^^ u256 + │ ^^^^^^ u256 note: ┌─ simple_open_auction.fe:59:28 diff --git a/crates/analyzer/tests/snapshots/analysis__strings.snap b/crates/analyzer/tests/snapshots/analysis__strings.snap index b902f24584..efed32f415 100644 --- a/crates/analyzer/tests/snapshots/analysis__strings.snap +++ b/crates/analyzer/tests/snapshots/analysis__strings.snap @@ -151,10 +151,10 @@ note: } note: - ┌─ strings.fe:31:16 + ┌─ strings.fe:31:13 │ 31 │ let s: String<18> = "fe" - │ ^^^^^^^^^^ String<18> + │ ^ String<18> note: ┌─ strings.fe:31:29 diff --git a/crates/analyzer/tests/snapshots/analysis__struct_fns.snap b/crates/analyzer/tests/snapshots/analysis__struct_fns.snap index 9bdccbb095..955e45482c 100644 --- a/crates/analyzer/tests/snapshots/analysis__struct_fns.snap +++ b/crates/analyzer/tests/snapshots/analysis__struct_fns.snap @@ -181,10 +181,10 @@ note: } note: - ┌─ struct_fns.fe:18:18 + ┌─ struct_fns.fe:18:13 │ 18 │ let old: u64 = self.x - │ ^^^ u64 + │ ^^^ u64 note: ┌─ struct_fns.fe:18:24 @@ -235,12 +235,12 @@ note: } note: - ┌─ struct_fns.fe:24:16 + ┌─ struct_fns.fe:24:13 │ 24 │ let x: u64 = self.x - │ ^^^ u64 + │ ^ u64 25 │ let y: u64 = self.y - │ ^^^ u64 + │ ^ u64 note: ┌─ struct_fns.fe:24:22 @@ -393,12 +393,12 @@ note: } note: - ┌─ struct_fns.fe:36:16 + ┌─ struct_fns.fe:36:13 │ 36 │ let x: u64 = self.x + other.x - │ ^^^ u64 + │ ^ u64 37 │ let y: u64 = self.y + other.y - │ ^^^ u64 + │ ^ u64 note: ┌─ struct_fns.fe:36:22 @@ -482,15 +482,15 @@ note: } note: - ┌─ struct_fns.fe:43:13 + ┌─ struct_fns.fe:43:9 │ 43 │ let p1: Point = Point::origin() - │ ^^^^^ Point + │ ^^ Point 44 │ p1.translate(x: 5, y: 10) 45 │ let p2: Point = Point(x: 1, y: 2) - │ ^^^^^ Point + │ ^^ Point 46 │ let p3: Point = p1.add(p2) - │ ^^^^^ Point + │ ^^ Point note: ┌─ struct_fns.fe:43:21 @@ -616,10 +616,10 @@ note: } note: - ┌─ struct_fns.fe:53:16 + ┌─ struct_fns.fe:53:13 │ 53 │ let p: Point = Point::new(x, y) - │ ^^^^^ Point + │ ^ Point note: ┌─ struct_fns.fe:52:9 diff --git a/crates/analyzer/tests/snapshots/analysis__structs.snap b/crates/analyzer/tests/snapshots/analysis__structs.snap index 3a067ab23f..55aeae8964 100644 --- a/crates/analyzer/tests/snapshots/analysis__structs.snap +++ b/crates/analyzer/tests/snapshots/analysis__structs.snap @@ -1097,10 +1097,10 @@ note: } note: - ┌─ structs.fe:83:18 + ┌─ structs.fe:83:13 │ 83 │ let val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) - │ ^^^ Bar + │ ^^^ Bar note: ┌─ structs.fe:83:34 @@ -1715,10 +1715,10 @@ note: } note: - ┌─ structs.fe:115:20 + ┌─ structs.fe:115:13 │ 115 │ let mixed: Mixed = Mixed::new(val: 1) - │ ^^^^^ Mixed + │ ^^^^^ Mixed note: ┌─ structs.fe:115:44 @@ -2435,10 +2435,10 @@ note: } note: - ┌─ structs.fe:156:23 + ┌─ structs.fe:156:13 │ 156 │ let building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) - │ ^^^^^ House + │ ^^^^^^^^ House note: ┌─ structs.fe:156:44 @@ -2715,10 +2715,10 @@ note: } note: - ┌─ structs.fe:176:20 + ┌─ structs.fe:176:13 │ 176 │ let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) - │ ^^^^^ House + │ ^^^^^ House note: ┌─ structs.fe:176:41 @@ -2774,10 +2774,10 @@ note: } note: - ┌─ structs.fe:181:20 + ┌─ structs.fe:181:13 │ 181 │ let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) - │ ^^^^^ House + │ ^^^^^ House note: ┌─ structs.fe:181:41 diff --git a/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap b/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap index aed5bda90e..823eb85780 100644 --- a/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap +++ b/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap @@ -676,12 +676,12 @@ note: } note: - ┌─ tuple_stress.fe:44:21 + ┌─ tuple_stress.fe:44:13 │ 44 │ let my_num: u256 = self.my_sto_tuple.item0 - │ ^^^^ u256 + │ ^^^^^^ u256 45 │ let my_tuple: (u256, bool, address) = (self.my_sto_tuple.item0, true and false, address(26)) - │ ^^^^^^^^^^^^^^^^^^^^^ (u256, bool, address) + │ ^^^^^^^^ (u256, bool, address) note: ┌─ tuple_stress.fe:44:28 diff --git a/crates/analyzer/tests/snapshots/analysis__type_aliases.snap b/crates/analyzer/tests/snapshots/analysis__type_aliases.snap index b3aca71cfc..2fc81178f8 100644 --- a/crates/analyzer/tests/snapshots/analysis__type_aliases.snap +++ b/crates/analyzer/tests/snapshots/analysis__type_aliases.snap @@ -106,10 +106,10 @@ note: } note: - ┌─ type_aliases.fe:23:17 + ┌─ type_aliases.fe:23:13 │ 23 │ let id: PostId = 0 - │ ^^^^^^ u256 + │ ^^ u256 note: ┌─ type_aliases.fe:23:26 @@ -213,10 +213,10 @@ note: } note: - ┌─ type_aliases.fe:30:20 + ┌─ type_aliases.fe:30:13 │ 30 │ let score: Score = self.scoreboard[id] + 1 - │ ^^^^^ u64 + │ ^^^^^ u64 note: ┌─ type_aliases.fe:30:28 diff --git a/crates/analyzer/tests/snapshots/analysis__uniswap.snap b/crates/analyzer/tests/snapshots/analysis__uniswap.snap index 8e33374d76..2fcb953342 100644 --- a/crates/analyzer/tests/snapshots/analysis__uniswap.snap +++ b/crates/analyzer/tests/snapshots/analysis__uniswap.snap @@ -1666,12 +1666,12 @@ note: } note: - ┌─ uniswap.fe:149:30 + ┌─ uniswap.fe:149:13 │ 149 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 - │ ^^^^ u256 + │ ^^^^^^^^^^^^^^^ u256 150 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last - │ ^^^^ u256 + │ ^^^^^^^^^^^^ u256 note: ┌─ uniswap.fe:149:37 @@ -1980,26 +1980,26 @@ note: } note: - ┌─ uniswap.fe:162:21 + ┌─ uniswap.fe:162:13 │ 162 │ let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() - │ ^^^^^^^ address + │ ^^^^^^ address 163 │ let fee_on: bool = fee_to != address(0) - │ ^^^^ bool + │ ^^^^^^ bool 164 │ let k_last: u256 = self.k_last - │ ^^^^ u256 + │ ^^^^^^ u256 · 167 │ let root_k: u256 = sqrt(reserve0 * reserve1) - │ ^^^^ u256 + │ ^^^^^^ u256 168 │ let root_k_last: u256 = sqrt(k_last) - │ ^^^^ u256 + │ ^^^^^^^^^^^ u256 169 │ if root_k > root_k_last { 170 │ let numerator: u256 = self.total_supply * root_k - root_k_last - │ ^^^^ u256 + │ ^^^^^^^^^ u256 171 │ let denominator: u256 = root_k * 5 + root_k_last - │ ^^^^ u256 + │ ^^^^^^^^^^^ u256 172 │ let liquidity: u256 = numerator / denominator - │ ^^^^ u256 + │ ^^^^^^^^^ u256 note: ┌─ uniswap.fe:162:48 @@ -2247,28 +2247,28 @@ note: } note: - ┌─ uniswap.fe:186:32 + ┌─ uniswap.fe:186:13 │ 186 │ let MINIMUM_LIQUIDITY: u256 = 1000 - │ ^^^^ u256 + │ ^^^^^^^^^^^^^^^^^ u256 187 │ let reserve0: u256 = self.reserve0 - │ ^^^^ u256 + │ ^^^^^^^^ u256 188 │ let reserve1: u256 = self.reserve1 - │ ^^^^ u256 + │ ^^^^^^^^ u256 189 │ let balance0: u256 = ERC20(ctx, self.token0).balanceOf(ctx.self_address()) - │ ^^^^ u256 + │ ^^^^^^^^ u256 190 │ let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) - │ ^^^^ u256 + │ ^^^^^^^^ u256 191 │ let amount0: u256 = balance0 - self.reserve0 - │ ^^^^ u256 + │ ^^^^^^^ u256 192 │ let amount1: u256 = balance1 - self.reserve1 - │ ^^^^ u256 + │ ^^^^^^^ u256 193 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) - │ ^^^^ bool + │ ^^^^^^ bool 194 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since totalSupply can update in _mintFee - │ ^^^^ u256 + │ ^^^^^^^^^^^^ u256 195 │ let liquidity: u256 = 0 - │ ^^^^ u256 + │ ^^^^^^^^^ u256 note: ┌─ uniswap.fe:186:39 @@ -2683,31 +2683,31 @@ note: } note: - ┌─ uniswap.fe:214:23 + ┌─ uniswap.fe:214:13 │ 214 │ let reserve0: u256 = self.reserve0 - │ ^^^^ u256 + │ ^^^^^^^^ u256 215 │ let reserve1: u256 = self.reserve1 - │ ^^^^ u256 + │ ^^^^^^^^ u256 216 │ let token0: ERC20 = ERC20(ctx, self.token0) - │ ^^^^^ ERC20 + │ ^^^^^^ ERC20 217 │ let token1: ERC20 = ERC20(ctx, self.token1) - │ ^^^^^ ERC20 + │ ^^^^^^ ERC20 218 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) - │ ^^^^ u256 + │ ^^^^^^^^ u256 219 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) - │ ^^^^ u256 + │ ^^^^^^^^ u256 220 │ let liquidity: u256 = self.balances[ctx.self_address()] - │ ^^^^ u256 + │ ^^^^^^^^^ u256 221 │ 222 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) - │ ^^^^ bool + │ ^^^^^^ bool 223 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since total_supply can update in _mintFee - │ ^^^^ u256 + │ ^^^^^^^^^^^^ u256 224 │ let amount0: u256 = (liquidity * balance0) / total_supply # using balances ensures pro-rata distribution - │ ^^^^ u256 + │ ^^^^^^^ u256 225 │ let amount1: u256 = (liquidity * balance1) / total_supply # using balances ensures pro-rata distribution - │ ^^^^ u256 + │ ^^^^^^^ u256 note: ┌─ uniswap.fe:214:30 @@ -3156,32 +3156,32 @@ note: } note: - ┌─ uniswap.fe:245:23 + ┌─ uniswap.fe:245:13 │ 245 │ let reserve0: u256 = self.reserve0 - │ ^^^^ u256 + │ ^^^^^^^^ u256 246 │ let reserve1: u256 = self.reserve1 - │ ^^^^ u256 + │ ^^^^^^^^ u256 · 249 │ let token0: ERC20 = ERC20(ctx, self.token0) - │ ^^^^^ ERC20 + │ ^^^^^^ ERC20 250 │ let token1: ERC20 = ERC20(ctx, self.token1) - │ ^^^^^ ERC20 + │ ^^^^^^ ERC20 · 265 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) - │ ^^^^ u256 + │ ^^^^^^^^ u256 266 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) - │ ^^^^ u256 + │ ^^^^^^^^ u256 267 │ 268 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 - │ ^^^^ u256 + │ ^^^^^^^^^^ u256 269 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 - │ ^^^^ u256 + │ ^^^^^^^^^^ u256 · 273 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 - │ ^^^^ u256 + │ ^^^^^^^^^^^^^^^^^ u256 274 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 - │ ^^^^ u256 + │ ^^^^^^^^^^^^^^^^^ u256 note: ┌─ uniswap.fe:244:16 @@ -3771,12 +3771,12 @@ note: } note: - ┌─ uniswap.fe:284:21 + ┌─ uniswap.fe:284:13 │ 284 │ let token0: ERC20 = ERC20(ctx, self.token0) # gas savings - │ ^^^^^ ERC20 + │ ^^^^^^ ERC20 285 │ let token1: ERC20 = ERC20(ctx, self.token1) # gas savings - │ ^^^^^ ERC20 + │ ^^^^^^ ERC20 note: ┌─ uniswap.fe:284:35 @@ -3931,12 +3931,12 @@ note: } note: - ┌─ uniswap.fe:292:21 + ┌─ uniswap.fe:292:13 │ 292 │ let token0: ERC20 = ERC20(ctx, self.token0) - │ ^^^^^ ERC20 + │ ^^^^^^ ERC20 293 │ let token1: ERC20 = ERC20(ctx, self.token1) - │ ^^^^^ ERC20 + │ ^^^^^^ ERC20 note: ┌─ uniswap.fe:292:35 @@ -4228,17 +4228,17 @@ note: } note: - ┌─ uniswap.fe:337:21 + ┌─ uniswap.fe:337:13 │ 337 │ let token0: address = token_a if token_a < token_b else token_b - │ ^^^^^^^ address + │ ^^^^^^ address 338 │ let token1: address = token_a if token_a > token_b else token_b - │ ^^^^^^^ address + │ ^^^^^^ address · 342 │ let salt: u256 = keccak256((token0, token1).abi_encode()) - │ ^^^^ u256 + │ ^^^^ u256 343 │ let pair: UniswapV2Pair = UniswapV2Pair.create2(ctx, 0, salt) - │ ^^^^^^^^^^^^^ UniswapV2Pair + │ ^^^^ UniswapV2Pair note: ┌─ uniswap.fe:335:16 @@ -4798,13 +4798,13 @@ note: } note: - ┌─ uniswap.fe:367:12 + ┌─ uniswap.fe:367:9 │ 367 │ let z: u256 - │ ^^^^ u256 + │ ^ u256 · 370 │ let x: u256 = val / 2 + 1 - │ ^^^^ u256 + │ ^ u256 note: ┌─ uniswap.fe:368:8 diff --git a/crates/analyzer/tests/snapshots/analysis__while_loop.snap b/crates/analyzer/tests/snapshots/analysis__while_loop.snap index 8d8879e6ac..5cd038deda 100644 --- a/crates/analyzer/tests/snapshots/analysis__while_loop.snap +++ b/crates/analyzer/tests/snapshots/analysis__while_loop.snap @@ -29,10 +29,10 @@ note: } note: - ┌─ while_loop.fe:3:18 + ┌─ while_loop.fe:3:13 │ 3 │ let val: u256 = 0 - │ ^^^^ u256 + │ ^^^ u256 note: ┌─ while_loop.fe:3:25 diff --git a/crates/analyzer/tests/snapshots/analysis__while_loop_with_break.snap b/crates/analyzer/tests/snapshots/analysis__while_loop_with_break.snap index 29ea6a30fd..c4c536fc90 100644 --- a/crates/analyzer/tests/snapshots/analysis__while_loop_with_break.snap +++ b/crates/analyzer/tests/snapshots/analysis__while_loop_with_break.snap @@ -29,10 +29,10 @@ note: } note: - ┌─ while_loop_with_break.fe:3:18 + ┌─ while_loop_with_break.fe:3:13 │ 3 │ let val: u256 = 0 - │ ^^^^ u256 + │ ^^^ u256 note: ┌─ while_loop_with_break.fe:3:25 diff --git a/crates/analyzer/tests/snapshots/analysis__while_loop_with_break_2.snap b/crates/analyzer/tests/snapshots/analysis__while_loop_with_break_2.snap index 5cb31858a3..1ace43a336 100644 --- a/crates/analyzer/tests/snapshots/analysis__while_loop_with_break_2.snap +++ b/crates/analyzer/tests/snapshots/analysis__while_loop_with_break_2.snap @@ -29,10 +29,10 @@ note: } note: - ┌─ while_loop_with_break_2.fe:3:18 + ┌─ while_loop_with_break_2.fe:3:13 │ 3 │ let val: u256 = 0 - │ ^^^^ u256 + │ ^^^ u256 note: ┌─ while_loop_with_break_2.fe:3:25 diff --git a/crates/analyzer/tests/snapshots/analysis__while_loop_with_continue.snap b/crates/analyzer/tests/snapshots/analysis__while_loop_with_continue.snap index 3ad21cdf94..46727e3ef9 100644 --- a/crates/analyzer/tests/snapshots/analysis__while_loop_with_continue.snap +++ b/crates/analyzer/tests/snapshots/analysis__while_loop_with_continue.snap @@ -29,12 +29,12 @@ note: } note: - ┌─ while_loop_with_continue.fe:3:16 + ┌─ while_loop_with_continue.fe:3:13 │ 3 │ let i: u256 = 0 - │ ^^^^ u256 + │ ^ u256 4 │ let counter: u256 = 0 - │ ^^^^ u256 + │ ^^^^^^^ u256 note: ┌─ while_loop_with_continue.fe:3:23 diff --git a/crates/parser/src/ast.rs b/crates/parser/src/ast.rs index d1e27d8e12..d91784a14e 100644 --- a/crates/parser/src/ast.rs +++ b/crates/parser/src/ast.rs @@ -382,15 +382,6 @@ impl Node { } } -impl Function { - pub fn is_pub(&self) -> bool { - self.pub_.is_some() - } - pub fn is_unsafe(&self) -> bool { - self.unsafe_.is_some() - } -} - impl Node { pub fn name(&self) -> &str { &self.kind.name.kind diff --git a/crates/parser/src/grammar/module.rs b/crates/parser/src/grammar/module.rs index e4c1023224..283f5acb89 100644 --- a/crates/parser/src/grammar/module.rs +++ b/crates/parser/src/grammar/module.rs @@ -45,9 +45,7 @@ pub fn parse_module_stmt(par: &mut Parser) -> ParseResult { TokenKind::Type => ModuleStmt::TypeAlias(parse_type_alias(par, None)?), TokenKind::Const => ModuleStmt::Constant(parse_constant(par, None)?), - // Let these be parse errors for now: TokenKind::Event => ModuleStmt::Event(parse_event_def(par, None)?), - // TokenKind::Name if par.peeked_text() == "from" => parse_from_import(par), TokenKind::Pub => { let pub_span = par.next()?.span; match par.peek_or_err()? { diff --git a/crates/parser/src/node.rs b/crates/parser/src/node.rs index 2e993dcf20..63cc93f28b 100644 --- a/crates/parser/src/node.rs +++ b/crates/parser/src/node.rs @@ -25,30 +25,13 @@ pub struct Node { pub kind: T, #[serde(skip_serializing, skip_deserializing)] pub id: NodeId, - #[serde(skip_serializing, skip_deserializing)] - pub original_id: NodeId, pub span: Span, } impl Node { pub fn new(kind: T, span: Span) -> Self { let id = NodeId::create(); - Self { - kind, - id, - original_id: id, - span, - } - } - - pub fn with_original_id(kind: T, span: Span, original_id: NodeId) -> Self { - let id = NodeId::create(); - Self { - kind, - id, - original_id, - span, - } + Self { kind, id, span } } } diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs index 74930859da..d5acb7bb05 100644 --- a/crates/parser/src/parser.rs +++ b/crates/parser/src/parser.rs @@ -118,19 +118,6 @@ impl<'a> Parser<'a> { self.peek_raw() } - /// Peek at the text of the next token, without consuming it. This is useful - /// for words that are keywords in some contexts, but not others. E.g. - /// `from` can be used as a variable or field name, but it's the leading - /// keyword of a `from x import y` statement. - /// - /// # Panics - /// This function must only be used in cases where the kind of the next - /// token has already been [`Parser::peek`]ed. If there is no next token, it - /// will panic. - pub fn peeked_text(&mut self) -> &'a str { - self.buffered.last().unwrap().text - } - fn peek_raw(&mut self) -> Option { if self.buffered.is_empty() { if let Some(tok) = self.lexer.next() {