@@ -1198,43 +1198,68 @@ impl Evaluation {
11981198 }
11991199 _ => { }
12001200 }
1201- if base. is_weak ( ) && let Some ( value) = & value. 0 {
1202- let base = base. upgrade_weak ( ) . unwrap ( ) ;
1203- let get_item = base. borrow ( ) . get_content_symbol ( "__getitem__" , u32:: MAX ) . symbols ;
1204- if get_item. len ( ) == 1 {
1205- let get_item = & get_item[ 0 ] ;
1206- let get_item = get_item. borrow ( ) ;
1207- if get_item. evaluations ( ) . is_some ( ) && get_item. evaluations ( ) . unwrap ( ) . len ( ) == 1 {
1208- let get_item_eval = & get_item. evaluations ( ) . unwrap ( ) [ 0 ] ;
1209- if let Some ( hook) = get_item_eval. symbol . get_symbol_hook . as_ref ( ) {
1210- let parent_file_or_func = parent. clone ( ) . borrow ( ) . parent_file_or_function ( ) . as_ref ( ) . unwrap ( ) . upgrade ( ) . unwrap ( ) ;
1211- let is_in_validation = match parent_file_or_func. borrow ( ) . typ ( ) . clone ( ) {
1212- SymType :: FILE | SymType :: PACKAGE ( _) | SymType :: FUNCTION => {
1213- parent_file_or_func. borrow ( ) . build_status ( BuildSteps :: VALIDATION ) == BuildStatus :: IN_PROGRESS
1214- } ,
1215- _ => { false }
1216- } ;
1201+ if !base. is_weak ( ) {
1202+ continue ;
1203+ }
1204+ let base = base. upgrade_weak ( ) . unwrap ( ) ;
1205+ let get_item_symbols = base. borrow ( ) . get_member_symbol (
1206+ session,
1207+ & S ! ( "__getitem__" ) ,
1208+ parent. borrow ( ) . find_module ( ) ,
1209+ false ,
1210+ false ,
1211+ true ,
1212+ true ,
1213+ false ,
1214+ ) . 0 ;
1215+ for get_item in get_item_symbols. iter ( ) {
1216+ let get_item = get_item. borrow ( ) ;
1217+ let Some ( evaluations) = get_item. evaluations ( ) else {
1218+ continue ;
1219+ } ;
1220+ for get_item_eval in evaluations {
1221+ if let Some ( hook) = get_item_eval. symbol . get_symbol_hook . as_ref ( ) {
1222+ let parent_file_or_func = parent. clone ( ) . borrow ( ) . parent_file_or_function ( ) . as_ref ( ) . unwrap ( ) . upgrade ( ) . unwrap ( ) ;
1223+ let is_in_validation = match parent_file_or_func. borrow ( ) . typ ( ) . clone ( ) {
1224+ SymType :: FILE | SymType :: PACKAGE ( _) | SymType :: FUNCTION => {
1225+ parent_file_or_func. borrow ( ) . build_status ( BuildSteps :: VALIDATION ) == BuildStatus :: IN_PROGRESS
1226+ } ,
1227+ _ => { false }
1228+ } ;
1229+ if let Some ( value) = & value. 0 {
12171230 context. as_mut ( ) . unwrap ( ) . insert ( S ! ( "args" ) , ContextValue :: STRING ( value. clone ( ) ) ) ;
1218- let old_range = context. as_mut ( ) . unwrap ( ) . remove ( & S ! ( "range" ) ) ;
1219- context. as_mut ( ) . unwrap ( ) . insert ( S ! ( "range" ) , ContextValue :: RANGE ( sub. slice . range ( ) ) ) ;
1220- context. as_mut ( ) . unwrap ( ) . insert ( S ! ( "is_in_validation" ) , ContextValue :: BOOLEAN ( is_in_validation) ) ;
1221- let hook_result = ( hook. callable ) ( session, & get_item_eval. symbol , context, & mut diagnostics, Some ( parent. clone ( ) ) ) ;
1222- if let Some ( hook_result) = hook_result {
1223- match hook_result {
1224- EvaluationSymbolPtr :: WEAK ( ref weak) => {
1225- if !weak. weak . is_expired ( ) {
1226- evals. push ( Evaluation :: eval_from_ptr ( & hook_result) ) ;
1227- }
1228- } ,
1229- _ => {
1231+ }
1232+ let old_range = context. as_mut ( ) . unwrap ( ) . remove ( & S ! ( "range" ) ) ;
1233+ context. as_mut ( ) . unwrap ( ) . insert ( S ! ( "range" ) , ContextValue :: RANGE ( sub. slice . range ( ) ) ) ;
1234+ context. as_mut ( ) . unwrap ( ) . insert ( S ! ( "is_in_validation" ) , ContextValue :: BOOLEAN ( is_in_validation) ) ;
1235+ let hook_result = ( hook. callable ) ( session, & get_item_eval. symbol , context, & mut diagnostics, Some ( parent. clone ( ) ) ) ;
1236+ if let Some ( hook_result) = hook_result {
1237+ match hook_result {
1238+ EvaluationSymbolPtr :: WEAK ( ref weak) => {
1239+ if !weak. weak . is_expired ( ) {
12301240 evals. push ( Evaluation :: eval_from_ptr ( & hook_result) ) ;
12311241 }
1242+ } ,
1243+ _ => {
1244+ evals. push ( Evaluation :: eval_from_ptr ( & hook_result) ) ;
12321245 }
12331246 }
1234- context. as_mut ( ) . unwrap ( ) . remove ( & S ! ( "args" ) ) ;
1235- context. as_mut ( ) . unwrap ( ) . remove ( & S ! ( "is_in_validation" ) ) ;
1236- context. as_mut ( ) . unwrap ( ) . insert ( S ! ( "range" ) , old_range. unwrap ( ) ) ;
12371247 }
1248+ context. as_mut ( ) . unwrap ( ) . remove ( & S ! ( "args" ) ) ;
1249+ context. as_mut ( ) . unwrap ( ) . remove ( & S ! ( "is_in_validation" ) ) ;
1250+ context. as_mut ( ) . unwrap ( ) . insert ( S ! ( "range" ) , old_range. unwrap ( ) ) ;
1251+ }
1252+ if let EvaluationSymbolPtr :: SELF = get_item_eval. symbol . get_symbol_ptr ( ) {
1253+ // Evaluate to the base itself
1254+ // For example for models, since you get the same type of recordset when subscripted
1255+ evals. push ( Evaluation {
1256+ symbol : EvaluationSymbol {
1257+ sym : EvaluationSymbolPtr :: WEAK ( EvaluationSymbolWeak { weak : Rc :: downgrade ( & base) , context : HashMap :: new ( ) , instance : Some ( true ) , is_super : false } ) ,
1258+ get_symbol_hook : None ,
1259+ } ,
1260+ value : None ,
1261+ range : Some ( sub. range ( ) )
1262+ } ) ;
12381263 }
12391264 }
12401265 }
0 commit comments