mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Merge pull request #5954 from yukiomoto/fix-num-related-crash
Fix crash caused by number related type error in repl
This commit is contained in:
commit
cc41f3a2f0
1 changed files with 45 additions and 32 deletions
|
@ -4268,7 +4268,8 @@ pub fn with_hole<'a>(
|
||||||
let arena = env.arena;
|
let arena = env.arena;
|
||||||
|
|
||||||
match can_expr {
|
match can_expr {
|
||||||
Int(_, _, int_str, int, _bound) => assign_num_literal_expr(
|
Int(_, _, int_str, int, _bound) => {
|
||||||
|
match assign_num_literal_expr(
|
||||||
env,
|
env,
|
||||||
layout_cache,
|
layout_cache,
|
||||||
assigned,
|
assigned,
|
||||||
|
@ -4276,9 +4277,14 @@ pub fn with_hole<'a>(
|
||||||
&int_str,
|
&int_str,
|
||||||
IntOrFloatValue::Int(int),
|
IntOrFloatValue::Int(int),
|
||||||
hole,
|
hole,
|
||||||
),
|
) {
|
||||||
|
Ok(stmt) => stmt,
|
||||||
|
Err(_) => hole.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Float(_, _, float_str, float, _bound) => assign_num_literal_expr(
|
Float(_, _, float_str, float, _bound) => {
|
||||||
|
match assign_num_literal_expr(
|
||||||
env,
|
env,
|
||||||
layout_cache,
|
layout_cache,
|
||||||
assigned,
|
assigned,
|
||||||
|
@ -4286,9 +4292,14 @@ pub fn with_hole<'a>(
|
||||||
&float_str,
|
&float_str,
|
||||||
IntOrFloatValue::Float(float),
|
IntOrFloatValue::Float(float),
|
||||||
hole,
|
hole,
|
||||||
),
|
) {
|
||||||
|
Ok(stmt) => stmt,
|
||||||
|
Err(_) => hole.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Num(_, num_str, num, _bound) => assign_num_literal_expr(
|
Num(_, num_str, num, _bound) => {
|
||||||
|
match assign_num_literal_expr(
|
||||||
env,
|
env,
|
||||||
layout_cache,
|
layout_cache,
|
||||||
assigned,
|
assigned,
|
||||||
|
@ -4296,7 +4307,11 @@ pub fn with_hole<'a>(
|
||||||
&num_str,
|
&num_str,
|
||||||
IntOrFloatValue::Int(num),
|
IntOrFloatValue::Int(num),
|
||||||
hole,
|
hole,
|
||||||
),
|
) {
|
||||||
|
Ok(stmt) => stmt,
|
||||||
|
Err(_) => hole.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Str(string) => Stmt::Let(
|
Str(string) => Stmt::Let(
|
||||||
assigned,
|
assigned,
|
||||||
|
@ -9267,14 +9282,12 @@ fn assign_num_literal_expr<'a>(
|
||||||
num_str: &str,
|
num_str: &str,
|
||||||
num_value: IntOrFloatValue,
|
num_value: IntOrFloatValue,
|
||||||
hole: &'a Stmt<'a>,
|
hole: &'a Stmt<'a>,
|
||||||
) -> Stmt<'a> {
|
) -> Result<Stmt<'a>, RuntimeError> {
|
||||||
let layout = layout_cache
|
let layout = layout_cache.from_var(env.arena, variable, env.subs)?;
|
||||||
.from_var(env.arena, variable, env.subs)
|
|
||||||
.unwrap();
|
|
||||||
let literal =
|
let literal =
|
||||||
make_num_literal(&layout_cache.interner, layout, num_str, num_value).to_expr_literal();
|
make_num_literal(&layout_cache.interner, layout, num_str, num_value).to_expr_literal();
|
||||||
|
|
||||||
Stmt::Let(assigned, Expr::Literal(literal), layout, hole)
|
Ok(Stmt::Let(assigned, Expr::Literal(literal), layout, hole))
|
||||||
}
|
}
|
||||||
|
|
||||||
type ToLowLevelCallArguments<'a> = (
|
type ToLowLevelCallArguments<'a> = (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue