33use std:: collections:: HashMap ;
44
55use compiler_typing:: {
6- enums:: RawEnumTypeContainer , raw:: RawType , references:: TypeReference ,
6+ TypedGlobalScopeEntry , enums:: RawEnumTypeContainer , raw:: RawType , references:: TypeReference ,
77 structs:: RawStructTypeContainer , transmutation:: array:: can_transmute_inner, tree:: Type ,
88} ;
99use compiler_utils:: {
@@ -13,7 +13,7 @@ use compiler_utils::{
1313} ;
1414use diagnostics:: {
1515 DiagnosticSpanOrigin ,
16- builders:: { make_diff_type, make_diff_type_val} ,
16+ builders:: { make_diff_type, make_diff_type_val, make_expected_simple_error_originless } ,
1717 diagnostic:: { Diagnostic , Span , SpanKind , SpanPosition } ,
1818 unsure_panic,
1919} ;
@@ -416,7 +416,9 @@ impl HIRNode {
416416 match & self . kind {
417417 HIRNodeKind :: VariableReference { index, is_static } => {
418418 if * is_static {
419- return Some ( context. static_variables . vals [ * index] . clone ( ) ) ;
419+ return Some (
420+ context. global_scope . scope . entries [ * index] . as_static_variable_unsafe ( ) ,
421+ ) ;
420422 }
421423
422424 return Some ( curr_ctx. variables [ * index] . variable_type . clone ( ) ) ;
@@ -490,9 +492,30 @@ impl HIRNode {
490492 func_name,
491493 arguments : _,
492494 } => {
493- let f = context. functions . vals [ * func_name] . 0 . clone ( ) ;
495+ //let f = context.functions.vals[*func_name].0.clone();
496+ let ind = match & context. global_scope . scope . entries [ * func_name] . entry_type {
497+ TypedGlobalScopeEntry :: Function {
498+ descriptor_ind,
499+ impl_ind : _,
500+ } => descriptor_ind,
501+ TypedGlobalScopeEntry :: ImplLessFunction ( ind) => ind,
502+ TypedGlobalScopeEntry :: StructFunction {
503+ descriptor_ind,
504+ impl_ind : _,
505+ struct_type : _,
506+ } => descriptor_ind,
507+
508+ _ => {
509+ make_expected_simple_error_originless (
510+ & "function" . to_string ( ) ,
511+ & context. global_scope . scope . entries [ * func_name] . entry_type ,
512+ ) ;
513+
514+ return None ;
515+ }
516+ } ;
494517
495- return f ;
518+ return context . global_scope . descriptors [ * ind ] . clone ( ) . 0 ;
496519 }
497520
498521 _ => return None ,
0 commit comments