Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Compiler issue with function inlining #3333

Open
arosboro opened this issue Nov 3, 2023 · 2 comments
Open

[Bug] Compiler issue with function inlining #3333

arosboro opened this issue Nov 3, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@arosboro
Copy link
Contributor

arosboro commented Nov 3, 2023

🐛 Bug Report

zk_deck_shuffle % leo build
Leo ⚠️ Attention - This command is deprecated. Use the 'run' command.

...

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/AleoHQ/leo/issues/new?labels=bug,panic&template=bug.md&title=[Bug]

note: leo-lang 1.10.0 running on Darwin 21.6.0

note: compiler args: leo build

note: compiler flags: CLI { debug: false, quiet: false, command: Build { command: Build { options: BuildOptions { offline: false, enable_symbol_table_spans: false, enable_initial_symbol_table_snapshot: false, enable_type_checked_symbol_table_snapshot: false, enable_unrolled_symbol_table_snapshot: false, enable_ast_spans: false, enable_dce: false, enable_all_ast_snapshots: false, enable_initial_input_ast_snapshot: false, enable_initial_ast_snapshot: false, enable_unrolled_ast_snapshot: false, enable_ssa_ast_snapshot: false, enable_flattened_ast_snapshot: false, enable_destructured_ast_snapshot: false, enable_inlined_ast_snapshot: false, enable_dce_ast_snapshot: false } } }, path: None }

Steps to Reproduce

clone https://github.com/zkCohor/zk_deck_shuffle.git
leo build

Code snippet to reproduce

[# Add code here](https://github.com/zkCohort/zk_deck_shuffle)

Stack trace & error message

thread `main` panicked at compiler/passes/src/function_inlining/inline_expression.rs:52:108:
called `Option::unwrap()` on a `None` value
stack backtrace: 
   0: backtrace::capture::Backtrace::new
   1: leo::set_panic_hook::{{closure}}
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::begin_panic_handler::{{closure}}
   4: std::sys_common::backtrace::__rust_end_short_backtrace
   5: _rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::panicking::panic
   8: leo_passes::function_inlining::inline_expression::<impl leo_ast::passes::reconstructor::ExpressionReconstructor for leo_passes::function_inlining::function_inliner::FunctionInliner>::reconstruct_call
   9: leo_ast::passes::reconstructor::ExpressionReconstructor::reconstruct_expression
  10: leo_passes::function_inlining::inline_statement::<impl leo_ast::passes::reconstructor::StatementReconstructor for leo_passes::function_inlining::function_inliner::FunctionInliner>::reconstruct_assign
  11: leo_ast::passes::reconstructor::StatementReconstructor::reconstruct_statement
  12: leo_passes::function_inlining::inline_statement::<impl leo_ast::passes::reconstructor::StatementReconstructor for leo_passes::function_inlining::function_inliner::FunctionInliner>::reconstruct_block
  13: leo_ast::passes::reconstructor::ProgramReconstructor::reconstruct_function
  14: leo_passes::function_inlining::inline_program::<impl leo_ast::passes::reconstructor::ProgramReconstructor for leo_passes::function_inlining::function_inliner::FunctionInliner>::reconstruct_program_scope
  15: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  16: <indexmap::map::IndexMap<K,V,S> as core::iter::traits::collect::FromIterator<(K,V)>>::from_iter
  17: leo_ast::passes::reconstructor::ProgramReconstructor::reconstruct_program
  18: leo_passes::function_inlining::<impl leo_passes::pass::Pass for leo_passes::function_inlining::function_inliner::FunctionInliner>::do_pass
  19: leo_compiler::compiler::Compiler::function_inlining_pass
  20: leo_compiler::compiler::Compiler::compiler_stages
  21: leo_compiler::compiler::Compiler::compile
  22: leo_lang::cli::commands::build::compile_leo_file
  23: <leo_lang::cli::commands::build::Build as leo_lang::cli::commands::Command>::apply
  24: leo_lang::cli::commands::Command::execute
  25: leo_lang::cli::commands::Command::try_execute
  26: leo_lang::cli::cli::run_with_args
  27: scoped_tls::ScopedKey<T>::set
  28: leo::main
  29: std::sys_common::backtrace::__rust_begin_short_backtrace
  30: std::rt::lang_start::{{closure}}
  31: std::rt::lang_start_internal
  32: std::rt::lang_start

Expected Behavior

What was supposed to happen in Leo? It was supposed to build correctly.

What happened instead? I got a panic.

(Write what you expected to happen here)

Your Environment

  • testnet3 updated Nov 2 2023
  • rustc 1.75.0-nightly (cd674d617 2023-10-24)
  • Mac OS Montery version 12.7
@arosboro arosboro added the bug Something isn't working label Nov 3, 2023
@arosboro
Copy link
Contributor Author

arosboro commented Nov 9, 2023

It's because I use the Stack struct in main.leo without classifying it to the correct scope I believe, I had filed a similar bug with @d0cd

@arosboro
Copy link
Contributor Author

arosboro commented Nov 9, 2023

part of the issue is when you call an inline which does not exist in scope as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants