Skip to main content

luaur_analysis/methods/
constraint_generator_fill_in_inferred_bindings.rs

1//! @interface-stub
2use crate::records::binding::Binding;
3use crate::records::constraint_generator::ConstraintGenerator;
4use crate::records::scope::Scope;
5use crate::records::symbol::Symbol;
6use crate::type_aliases::scope_ptr_constraint_generator::ScopePtr;
7use crate::type_aliases::type_id::TypeId;
8use alloc::string::String;
9use alloc::vec::Vec;
10use luaur_ast::records::ast_stat_block::AstStatBlock;
11use luaur_ast::records::location::Location;
12
13impl ConstraintGenerator {
14    pub fn fill_in_inferred_bindings(
15        &mut self,
16        _global_scope: &ScopePtr,
17        _block: *mut AstStatBlock,
18    ) {
19        let inferred_bindings: Vec<(Symbol, *mut Scope, Location, Vec<TypeId>)> = self
20            .inferred_bindings
21            .iter()
22            .map(|(symbol, p)| (symbol.clone(), p.scope, p.location, p.types.order.clone()))
23            .collect();
24
25        for (symbol, scope, location, tys) in inferred_bindings {
26            let ty = if tys.len() == 1 {
27                tys[0]
28            } else {
29                self.make_union_vector_type_id(tys)
30            };
31
32            unsafe {
33                (*scope).bindings.insert(
34                    symbol,
35                    Binding {
36                        type_id: ty,
37                        location,
38                        deprecated: false,
39                        deprecated_suggestion: String::new(),
40                        documentation_symbol: None,
41                    },
42                );
43            }
44        }
45    }
46}