From 5fce6cf069b1552ba48c1c5a11748f228b080fcc Mon Sep 17 00:00:00 2001 From: pca006132 Date: Fri, 15 Jan 2021 14:37:55 +0800 Subject: [PATCH] updated lifetime --- nac3core/src/type_check/signature.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/nac3core/src/type_check/signature.rs b/nac3core/src/type_check/signature.rs index 32654b78d5..818952525f 100644 --- a/nac3core/src/type_check/signature.rs +++ b/nac3core/src/type_check/signature.rs @@ -5,7 +5,9 @@ use super::typedef::*; use rustpython_parser::ast::{ExpressionType, Statement, StatementType, StringGroup}; use std::collections::HashMap; -fn typename_from_expr<'b: 'a, 'a>(typenames: &mut Vec<&'a str>, expr: &'b ExpressionType) { +// TODO: fix condition checking, return error message instead of panic... + +fn typename_from_expr<'a>(typenames: &mut Vec<&'a str>, expr: &'a ExpressionType) { match expr { ExpressionType::Identifier { name } => typenames.push(&name), ExpressionType::String { value } => match value { @@ -20,7 +22,7 @@ fn typename_from_expr<'b: 'a, 'a>(typenames: &mut Vec<&'a str>, expr: &'b Expres } } -fn typename_from_fn<'b: 'a, 'a>(typenames: &mut Vec<&'a str>, fun: &'b StatementType) { +fn typename_from_fn<'a>(typenames: &mut Vec<&'a str>, fun: &'a StatementType) { match fun { StatementType::FunctionDef { args, returns, .. } => { for arg in args.args.iter() { @@ -36,7 +38,7 @@ fn typename_from_fn<'b: 'a, 'a>(typenames: &mut Vec<&'a str>, fun: &'b Statement } } -fn name_from_expr<'b: 'a, 'a>(expr: &'b ExpressionType) -> &'a str { +fn name_from_expr<'a>(expr: &'a ExpressionType) -> &'a str { match &expr { ExpressionType::Identifier { name } => &name, ExpressionType::String { value } => match value { @@ -47,9 +49,9 @@ fn name_from_expr<'b: 'a, 'a>(expr: &'b ExpressionType) -> &'a str { } } -fn type_from_expr<'b: 'a, 'a>( +fn type_from_expr<'a>( ctx: &'a TopLevelContext, - expr: &'b ExpressionType, + expr: &'a ExpressionType, ) -> Result { match expr { ExpressionType::Identifier { name } => { @@ -90,7 +92,7 @@ fn type_from_expr<'b: 'a, 'a>( } } -pub fn get_typenames<'b: 'a, 'a>(stmts: &'b [Statement]) -> (Vec<&'a str>, Vec<&'a str>) { +pub fn get_typenames<'a>(stmts: &'a [Statement]) -> (Vec<&'a str>, Vec<&'a str>) { let mut classes = Vec::new(); let mut typenames = Vec::new(); for stmt in stmts.iter() { @@ -134,9 +136,9 @@ pub fn get_typenames<'b: 'a, 'a>(stmts: &'b [Statement]) -> (Vec<&'a str>, Vec<& (classes, unknowns) } -fn resolve_function<'b: 'a, 'a>( +fn resolve_function<'a>( ctx: &'a TopLevelContext, - fun: &'b StatementType, + fun: &'a StatementType, method: bool, ) -> Result { if let StatementType::FunctionDef { args, returns, .. } = &fun { @@ -159,7 +161,7 @@ fn resolve_function<'b: 'a, 'a>( } } -pub fn resolve_signatures<'b: 'a, 'a>(ctx: &mut TopLevelContext<'a>, stmts: &'b [Statement]) { +pub fn resolve_signatures<'a>(ctx: &mut TopLevelContext<'a>, stmts: &'a [Statement]) { for stmt in stmts.iter() { match &stmt.node { StatementType::ClassDef {