Add module loading validity checks
This commit is contained in:
@@ -90,7 +90,7 @@ impl Target for LuaJIT {
|
||||
Wat::Module(ast) => ast.encode().unwrap(),
|
||||
Wat::Component(_) => unimplemented!(),
|
||||
};
|
||||
let data = Module::from_data(&bytes);
|
||||
let data = Module::try_from_data(&bytes).unwrap();
|
||||
|
||||
writeln!(w, "assert_trap((function()")?;
|
||||
codegen_luajit::from_module_untyped(&data, w)?;
|
||||
|
||||
@@ -103,7 +103,7 @@ impl Target for Luau {
|
||||
Wat::Module(ast) => ast.encode().unwrap(),
|
||||
Wat::Component(_) => unimplemented!(),
|
||||
};
|
||||
let data = Module::from_data(&bytes);
|
||||
let data = Module::try_from_data(&bytes).unwrap();
|
||||
|
||||
writeln!(w, "assert_trap((function()")?;
|
||||
codegen_luau::from_module_untyped(&data, w)?;
|
||||
|
||||
@@ -81,7 +81,7 @@ pub trait Target: Sized {
|
||||
let mut ast = try_into_ast_module(data).expect("Must be a module");
|
||||
let bytes = ast.encode().unwrap();
|
||||
|
||||
let data = AstModule::from_data(&bytes);
|
||||
let data = AstModule::try_from_data(&bytes).unwrap();
|
||||
let name = ast.id.as_ref().map(Id::name);
|
||||
|
||||
Self::write_module(&data, name, w)?;
|
||||
|
||||
Reference in New Issue
Block a user