mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
parent
530fa9943a
commit
fe1cbc2261
2 changed files with 32 additions and 15 deletions
|
@ -281,7 +281,7 @@ fn jit_to_ast_help<'a, A: ReplApp<'a>>(
|
||||||
let (newtype_containers, content) = unroll_newtypes(env, content);
|
let (newtype_containers, content) = unroll_newtypes(env, content);
|
||||||
let content = unroll_aliases(env, content);
|
let content = unroll_aliases(env, content);
|
||||||
|
|
||||||
macro_rules! helper {
|
macro_rules! num_helper {
|
||||||
($ty:ty) => {
|
($ty:ty) => {
|
||||||
app.call_function(main_fn_name, |_, num: $ty| {
|
app.call_function(main_fn_name, |_, num: $ty| {
|
||||||
num_to_ast(env, number_literal_to_ast(env.arena, num), content)
|
num_to_ast(env, number_literal_to_ast(env.arena, num), content)
|
||||||
|
@ -297,21 +297,24 @@ fn jit_to_ast_help<'a, A: ReplApp<'a>>(
|
||||||
Layout::Builtin(Builtin::Int(int_width)) => {
|
Layout::Builtin(Builtin::Int(int_width)) => {
|
||||||
use IntWidth::*;
|
use IntWidth::*;
|
||||||
|
|
||||||
let result = match int_width {
|
let result = match (content, int_width) {
|
||||||
U8 | I8 => {
|
(Content::Structure(FlatType::Apply(Symbol::NUM_NUM, _)), U8) => num_helper!(u8),
|
||||||
// NOTE: `helper!` does not handle 8-bit numbers yet
|
(_, U8) => {
|
||||||
|
// This is not a number, it's a tag union or something else
|
||||||
app.call_function(main_fn_name, |mem: &A::Memory, num: u8| {
|
app.call_function(main_fn_name, |mem: &A::Memory, num: u8| {
|
||||||
byte_to_ast(env, mem, num, content)
|
byte_to_ast(env, mem, num, content)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
U16 => helper!(u16),
|
// The rest are numbers... for now
|
||||||
U32 => helper!(u32),
|
(_, U16) => num_helper!(u16),
|
||||||
U64 => helper!(u64),
|
(_, U32) => num_helper!(u32),
|
||||||
U128 => helper!(u128),
|
(_, U64) => num_helper!(u64),
|
||||||
I16 => helper!(i16),
|
(_, U128) => num_helper!(u128),
|
||||||
I32 => helper!(i32),
|
(_, I8) => num_helper!(i8),
|
||||||
I64 => helper!(i64),
|
(_, I16) => num_helper!(i16),
|
||||||
I128 => helper!(i128),
|
(_, I32) => num_helper!(i32),
|
||||||
|
(_, I64) => num_helper!(i64),
|
||||||
|
(_, I128) => num_helper!(i128),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
@ -320,14 +323,14 @@ fn jit_to_ast_help<'a, A: ReplApp<'a>>(
|
||||||
use FloatWidth::*;
|
use FloatWidth::*;
|
||||||
|
|
||||||
let result = match float_width {
|
let result = match float_width {
|
||||||
F32 => helper!(f32),
|
F32 => num_helper!(f32),
|
||||||
F64 => helper!(f64),
|
F64 => num_helper!(f64),
|
||||||
F128 => todo!("F128 not implemented"),
|
F128 => todo!("F128 not implemented"),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
Layout::Builtin(Builtin::Decimal) => Ok(helper!(RocDec)),
|
Layout::Builtin(Builtin::Decimal) => Ok(num_helper!(RocDec)),
|
||||||
Layout::Builtin(Builtin::Str) => {
|
Layout::Builtin(Builtin::Str) => {
|
||||||
let size = layout.stack_size(env.target_info) as usize;
|
let size = layout.stack_size(env.target_info) as usize;
|
||||||
Ok(
|
Ok(
|
||||||
|
|
|
@ -1051,3 +1051,17 @@ fn dec_in_repl() {
|
||||||
r#"1.23 : Dec"#,
|
r#"1.23 : Dec"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn print_i8_issue_2710() {
|
||||||
|
expect_success(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
a : I8
|
||||||
|
a = -1
|
||||||
|
a
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
r#"-1 : I8"#,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue