Fix tab character at the start of a script causing it not to parse correctly (#72)

This commit is contained in:
AsynchronousMatrix 2023-07-19 20:34:52 +01:00 committed by GitHub
parent 9e28822e8f
commit 7237b7819a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@ use std::process::ExitCode;
use lua::task::{TaskScheduler, TaskSchedulerResumeExt, TaskSchedulerScheduleExt};
use mlua::prelude::*;
use mlua::Compiler as LuaCompiler;
use tokio::task::LocalSet;
pub(crate) mod builtins;
@ -68,6 +69,7 @@ impl Lune {
) -> Result<ExitCode, LuaError> {
// Create our special lune-flavored Lua object with extra registry values
let lua = lua::create_lune_lua()?;
let script_bytecode = LuaCompiler::default().compile(script_contents);
// Create our task scheduler and all globals
// NOTE: Some globals require the task scheduler to exist on startup
let sched = TaskScheduler::new(lua)?.into_static();
@ -75,7 +77,7 @@ impl Lune {
importer::create(lua, self.args.clone())?;
// Create the main thread and schedule it
let main_chunk = lua
.load(script_contents.as_ref())
.load(script_bytecode)
.set_name(script_name.as_ref())
.into_function()?;
let main_thread = lua.create_thread(main_chunk)?;