-
Notifications
You must be signed in to change notification settings - Fork 189
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
Unreachable code: logging this expression type is not supported #1035
Comments
The code is crashing builtin::Opcode::Println(_) => {
// Compiler sanity check. This should be caught during typechecking
assert_eq!(
arguments.len(),
1,
"print statements currently only support one argument"
);
let is_string = match &arguments[0] {
Expression::Ident(ident) => match ident.typ {
Type::String(_) => true,
Type::Tuple(_) => {
unreachable!("logging structs/tuples is not supported")
}
Type::Function { .. } => {
unreachable!("logging functions is not supported")
}
_ => false,
},
Expression::Literal(literal) => matches!(literal, Literal::Str(_)),
_ => unreachable!("logging this expression type is not supported"),
};
Some(builtin::Opcode::Println(builtin::PrintlnInfo {
is_string_output: is_string,
show_output: true,
}))
} This is checking for variables/literals while constructing the ssa instead of after its optimizations are finished. If we delay this check until after the optimizations, the code used in the example will become literal values rather than a field access and this existing check should print it just fine. |
@vezenovm what is the status of this issue with the new ssa code? |
This looks like it may be a separate issue with the new SSA code @jfecher: use dep::std;
struct RV<T> {
value: T,
count: comptime Field,
}
impl<T> RV<T> {
fn new(value: T) -> Self {
Self { value, count: 1 }
}
fn increment(mut this: Self) -> Self {
this.count += 1;
this
}
fn print(self) {
for _i in 0..self.count {
// std::println(self.value);
}
}
}
fn main() {
let mut rv = RV::new(5);
rv = rv.increment();
rv.print();
} I'm getting the same error with the
|
The same error occurs for this issue: #1367, with or without the println |
The join point error is a result of using the mutable comptime variable as a loop bound. Unfortunately mutability and comptime don't play well together since our pass to remove mutability is after unrolling rather than before. Adding this pass before unrolling fixes the issue but I'm unsure if it causes other bugs as well. |
Aim
Trying to compile the program:
Expected behavior
Expected the program to be compile and for 5 to be printed twice.
Bug
Compiler crashes after hitting an
unreachable!
line:To reproduce
Installation method
None
Nargo version
No response
@noir-lang/noir_wasm version
No response
@noir-lang/barretenberg version
No response
@noir-lang/aztec_backend version
No response
Additional context
No response
Submission Checklist
The text was updated successfully, but these errors were encountered: