# Compiler crash \[\]

**URL:** <https://forums.sui.io/t/compiler-crash/44935>\
**Category:** Move\
**Created:** [August 11, 2023, 11:41pm UTC](https://forums.sui.io/t/compiler-crash/44935 "2023-08-11T23:41:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shiqicao](https://dub1.discourse-cdn.com/sui/user_avatar/forums.sui.io/shiqicao/32/30473_2.png) [@shiqicao](https://forums.sui.io/u/shiqicao)\
**Post date:** [August 11, 2023, 11:41pm UTC](https://forums.sui.io/t/compiler-crash/44935/1 "2023-08-11T23:41:49Z")

</div>

repro, [git@github.com](mailto:git@github.com):shiqicao/move\_repro.git  
version, sui 1.7.0-362c5c3f2

stack

```auto
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', external-crates/move/move-compiler/src/sui_mode/id_leak.rs:138:56
stack backtrace:
2023-08-11T23:40:28.412189Z ERROR telemetry_subscribers: panicked at 'called `Option::unwrap()` on a `None` value', external-crates/move/move-compiler/src/sui_mode/id_leak.rs:138:56 panic.file="external-crates/move/move-compiler/src/sui_mode/id_leak.rs" panic.line=138 panic.column=56
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: <move_compiler::sui_mode::id_leak::IDLeakVerifierAI as move_compiler::cfgir::visitor::SimpleAbsInt>::exp_custom
   4: move_compiler::cfgir::visitor::SimpleAbsInt::exp
   5: <V as move_compiler::cfgir::visitor::AbstractInterpreterVisitor>::verify
   6: move_compiler::cfgir::translate::visit_function
   7: move_compiler::cfgir::translate::program
   8: move_compiler::command_line::compiler::run
   9: move_compiler::command_line::compiler::run
  10: move_compiler::command_line::compiler::run
  11: move_compiler::command_line::compiler::run
  12: move_compiler::command_line::compiler::run
  13: move_compiler::command_line::compiler::SteppedCompiler<_>::run
  14: move_compiler::command_line::compiler::Compiler::run
  15: move_compiler::command_line::compiler::Compiler::build
  16: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  17: move_package::compilation::compiled_package::CompiledPackage::build_all
  18: move_package::compilation::build_plan::BuildPlan::compile_with_driver
  19: sui_move_build::build_from_resolution_graph
  20: sui_move_build::BuildConfig::build
  21: sui_move::build::Build::execute_internal
  22: sui_move::build::Build::execute
  23: sui_move::execute_move_command
  24: sui::sui_commands::SuiCommand::execute::{{closure}}
  25: tokio::runtime::park::CachedParkThread::block_on
  26: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
  27: tokio::runtime::runtime::Runtime::block_on
  28: sui::main

```

---

<div class="post-metadata">

**Author:** ![manosliolios](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@manosliolios](https://forums.sui.io/u/manosliolios)\
**Post date:** [August 15, 2023, 7:40pm UTC](https://forums.sui.io/t/compiler-crash/44935/2 "2023-08-15T19:40:42Z")

</div>

@shiqicao noticing that it happens on build time.

You’re trying to construct a struct outside of its definition module, which is not possible (as they are private).

To generate a struct outside of the defining module, you’d need a function that creates a struct and returns it inside the `foo` module itself.

e.g.

```auto
public fun create_foo(): Foo {
    Foo {}
}

```

But, **keep in mind** that this is a public function and anyone could create a struct of type Foo. There are a few ways to guard this:

1. Adding some business logic based on which you’d return a `Foo`.
2. Using a public(friend) function and making the module a friend.
3. Authentication mechanisms to protect it. [(Suifrens uses this technique)](https://github.com/MystenLabs/apps/blob/c9e4304066953089701e38cf6bb91a23168bd0de/suifrens/suifrens/sources/suifrens.move#L212)

Also, it’s recommended you use the [Sui Move Analyzer](https://blog.sui.io/move-analyzer-tutorial/) to catch these issues earlier and improve your development experience!

 ![Screenshot 2023-08-15 at 10.39.05 PM](https://europe1.discourse-cdn.com/sui/original/3X/8/3/83b8d2a36bbef52fa78d37cb0c366ae1be19b23f.png)

---

<div class="post-metadata">

**Author:** ![shiqicao](https://dub1.discourse-cdn.com/sui/user_avatar/forums.sui.io/shiqicao/32/30473_2.png) [@shiqicao](https://forums.sui.io/u/shiqicao)\
**Post date:** [August 15, 2023, 7:55pm UTC](https://forums.sui.io/t/compiler-crash/44935/3 "2023-08-15T19:55:13Z")

</div>

This is a bug report for the compiler, it is a must fix.
