leo
leo copied to clipboard
[Bug] Char causes compiler to panic
🐛 Bug Report
Using char seems to be broken as a datatype.
The full code is:
// The `Oracle` record datatype.
record Oracle {
// The oracle owner.
owner: address,
// The Aleo balance (in gates).
gates: u64,
// The oracle set price.
price: u64,
// Symbol
symbol: char,
}
// The `initialize` function initializes a new record with the
// to the receiver of oracles in `r1` for the receiver in `r0`.
@program
function initialize(owner: address, symbol: char) -> Oracle {
return Oracle {
owner: owner,
gates: 0u64,
price: 0u64,
symbol: symbol
};
}
// The `update` function creates a new record to update the price
@program
function update(oracle: Oracle, price: u64) -> (Oracle, Oracle) {
// Produce a oracle record with an updated price
return Oracle {
owner: oracle.owner,
gates: oracle.gates,
price: price,
symbol: oracle.symbol
};
}
Steps to Reproduce
leo build
Stack trace & error message
thread `main` panicked at 'internal error: entered unreachable code: All composite types should be known at this phase of compilation', compiler/passes/src/code_generation/visit_type.rs:45:21
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: leo_passes::code_generation::visit_type::<impl leo_passes::code_generation::generator::CodeGenerator>::visit_type_with_visibility
8: leo_passes::code_generation::visit_program::<impl leo_passes::code_generation::generator::CodeGenerator>::visit_program
9: leo_passes::code_generation::<impl leo_passes::pass::Pass for leo_passes::code_generation::generator::CodeGenerator>::do_pass
10: leo_compiler::compiler::Compiler::compile_and_generate_instructions
11: leo::commands::build::compile_leo_file
12: <leo::commands::build::Build as leo::commands::Command>::apply
13: leo::commands::Command::execute
14: leo::commands::Command::try_execute
15: leo::run_with_args
16: scoped_tls::ScopedKey<T>::set
17: leo::main
18: std::sys_common::backtrace::__rust_begin_short_backtrace
19: std::rt::lang_start::{{closure}}
20: std::rt::lang_start_internal
21: _main
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.5.3 running on Darwin 21.5.0
note: compiler args: ../../leo/target/release/leo build
note: compiler flags: CLI { debug: false, quiet: false, command: Build { command: Build { compiler_options: BuildOptions { offline: false, enable_spans: 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_code_generation: false } } }, api: None, path: None }
Expected Behavior
The compiler should not panic and ask me to file bug reports.
Your Environment
rustc 1.65.0-nightly leo-lang 1.5.3 running on Darwin 21.5.0
Thanks for filing this bug!
As a heads up, Leo does not currently support the char datatype.
The fix in #2014 will error appropriately for the example above.