fix: improve JIT compiler error messages
Show specific expression type when JIT compilation fails, e.g.: - "Unsupported in JIT: String literal" - "Effect operation 'Console.print' - effects are not supported in JIT" - "ADT constructor 'Success' - algebraic data types are not supported in JIT" This helps users understand exactly which expression is blocking JIT compilation instead of a generic "Unsupported expression type". Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -464,9 +464,44 @@ fn compile_expr(
|
||||
compile_expr(builder, block_result, variables, current_var, func_ids, module)
|
||||
}
|
||||
|
||||
_ => Err(CompileError {
|
||||
message: "Unsupported expression type".to_string(),
|
||||
}),
|
||||
expr => {
|
||||
let expr_type = match expr {
|
||||
Expr::Literal(lit) => match lit {
|
||||
Literal::String(_) => "String literal",
|
||||
Literal::Float(_) => "Float literal",
|
||||
Literal::Char(_) => "Char literal",
|
||||
Literal::Unit => "Unit literal",
|
||||
_ => "Literal",
|
||||
},
|
||||
Expr::EffectOp { effect, operation, .. } => {
|
||||
return Err(CompileError {
|
||||
message: format!("Effect operation '{}.{}' - effects are not supported in JIT",
|
||||
effect.name, operation.name),
|
||||
});
|
||||
}
|
||||
Expr::Field { .. } => "Field access (records)",
|
||||
Expr::Lambda { .. } => "Lambda/closure",
|
||||
Expr::Match { .. } => "Match expression",
|
||||
Expr::List { .. } => "List literal",
|
||||
Expr::Record { .. } => "Record literal",
|
||||
Expr::Tuple { .. } => "Tuple literal",
|
||||
Expr::Index { .. } => "Index access",
|
||||
Expr::Run { .. } => "Run expression (effects)",
|
||||
Expr::Handle { .. } => "Handle expression (effects)",
|
||||
Expr::Resume { .. } => "Resume expression (effects)",
|
||||
Expr::Pipe { .. } => "Pipe operator",
|
||||
Expr::Interpolation { .. } => "String interpolation",
|
||||
Expr::Constructor { name, .. } => {
|
||||
return Err(CompileError {
|
||||
message: format!("ADT constructor '{}' - algebraic data types are not supported in JIT", name.name),
|
||||
});
|
||||
}
|
||||
_ => "Unknown expression",
|
||||
};
|
||||
Err(CompileError {
|
||||
message: format!("Unsupported in JIT: {}", expr_type),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user