diff --git a/nac3core/src/toplevel/composer.rs b/nac3core/src/toplevel/composer.rs index bd9a9214..82767ae1 100644 --- a/nac3core/src/toplevel/composer.rs +++ b/nac3core/src/toplevel/composer.rs @@ -434,7 +434,7 @@ impl TopLevelComposer { location: Location, ) -> Result<(StrRef, DefinitionId, Option), String> { if self.keyword_list.contains(&name) { - return Err(format!("cannot use keyword `{name}` as a class name (at {location})")); + return Err(format!("cannot use keyword `{name}` as a variable name (at {location})")); } let global_var_name = @@ -469,10 +469,10 @@ impl TopLevelComposer { self.analyze_top_level_class_definition()?; self.analyze_top_level_class_fields_methods()?; self.analyze_top_level_function()?; + self.analyze_top_level_variables()?; if inference { self.analyze_function_instance()?; } - self.analyze_top_level_variables()?; Ok(()) } @@ -1410,7 +1410,7 @@ impl TopLevelComposer { Ok(()) } - /// step 4, analyze and call type inferencer to fill the `instance_to_stmt` of + /// step 5, analyze and call type inferencer to fill the `instance_to_stmt` of /// [`TopLevelDef::Function`] fn analyze_function_instance(&mut self) -> Result<(), HashSet> { // first get the class constructor type correct for the following type check in function body @@ -1941,7 +1941,7 @@ impl TopLevelComposer { Ok(()) } - /// Step 5. Analyze and populate the types of global variables. + /// Step 4. Analyze and populate the types of global variables. fn analyze_top_level_variables(&mut self) -> Result<(), HashSet> { let def_list = &self.definition_ast_list; let temp_def_list = self.extract_def_list();