Skip to main content

luaur_compiler/methods/
compiler_check_exported_local.rs

1use crate::records::compiler::Compiler;
2use luaur_ast::records::ast_local::AstLocal;
3use luaur_ast::records::location::Location;
4use luaur_common::functions::vformat::vformat;
5use luaur_common::macros::luau_noinline::LUAU_NOINLINE;
6
7impl Compiler {
8    pub fn check_exported_local(&mut self, local: *mut AstLocal, location: &Location) {
9        unsafe {
10            if (*local).is_exported {
11                if !self.at_top_level() {
12                    // C++ `CompileError::raise(...)`: throw a typed CompileError, not a String.
13                    crate::records::compile_error::CompileError::raise(
14                        location,
15                        format_args!("'export' may only be applied to top-level statements"),
16                    );
17                }
18
19                self.exported_locals.push(local);
20            }
21        }
22    }
23}