mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-11-05 04:51:40 +03:00
Dont desugar snil in errors
This commit is contained in:
parent
38b479d731
commit
9b7719d7f0
@ -219,17 +219,20 @@ impl<'a> Reader<'a> {
|
||||
Term::App { fun: box Term::App { fun: ctr, arg: box Term::Num { val }, .. }, arg: tail, .. } => {
|
||||
let tail = Self::resugar_string(tail, snil);
|
||||
let char: String = unsafe { char::from_u32_unchecked(*val as u32) }.into();
|
||||
if let Term::Str { val: tail } = tail {
|
||||
Term::Str { val: char + &tail }
|
||||
} else {
|
||||
// FIXME: warnings are not good with this resugar
|
||||
// Just make the constructor again
|
||||
let fun = Term::App { tag: Tag::Static, fun: ctr.clone(), arg: Box::new(Term::Num { val: *val }) };
|
||||
Term::App { tag: Tag::Static, fun: Box::new(fun), arg: Box::new(tail) }
|
||||
match tail {
|
||||
Term::Str { val: tail } => Term::Str { val: char + &tail },
|
||||
Term::Ref { def_id } if def_id == *snil => Term::Str { val: char },
|
||||
_ => {
|
||||
// FIXME: warnings are not good with this resugar
|
||||
// Just make the constructor again
|
||||
let fun =
|
||||
Term::App { tag: Tag::Static, fun: ctr.clone(), arg: Box::new(Term::Num { val: *val }) };
|
||||
Term::App { tag: Tag::Static, fun: Box::new(fun), arg: Box::new(tail) }
|
||||
}
|
||||
}
|
||||
}
|
||||
// (SNil)
|
||||
Term::Ref { def_id } if def_id == snil => Term::Str { val: String::new() },
|
||||
// Term::Ref { def_id } if def_id == snil => Term::Str { val: String::new() },
|
||||
other => std::mem::take(other),
|
||||
}
|
||||
}
|
||||
|
@ -2,4 +2,4 @@
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/run_file/nested_str.hvm
|
||||
---
|
||||
(((SCons "a" ""), (SCons 97 (SCons "bc" ""))), ((SCons "ab" "c"), (SCons "ab" (SCons "cd" ""))))
|
||||
(((SCons "a" SNil), (SCons 97 (SCons "bc" SNil))), ((SCons "ab" "c"), (SCons "ab" (SCons "cd" SNil))))
|
||||
|
@ -2,4 +2,4 @@
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/run_file/unaplied_str.hvm
|
||||
---
|
||||
λa λb (SCons a (SCons 98 (SCons 99 (SCons b ""))))
|
||||
λa λb (SCons a (SCons 98 (SCons 99 (SCons b SNil))))
|
||||
|
@ -2,4 +2,4 @@
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/run_file/wrong_string.hvm
|
||||
---
|
||||
(SCons (*, 4) (SCons * ""))
|
||||
(SCons (*, 4) (SCons * SNil))
|
||||
|
@ -2,4 +2,4 @@
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/run_lazy/nested_str.hvm
|
||||
---
|
||||
(((SCons "a" ""), (SCons 97 (SCons "bc" ""))), ((SCons "ab" "c"), (SCons "ab" (SCons "cd" ""))))
|
||||
(((SCons "a" SNil), (SCons 97 (SCons "bc" SNil))), ((SCons "ab" "c"), (SCons "ab" (SCons "cd" SNil))))
|
||||
|
@ -2,4 +2,4 @@
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/run_lazy/unaplied_str.hvm
|
||||
---
|
||||
λa λb (SCons a (SCons 98 (SCons 99 (SCons b ""))))
|
||||
λa λb (SCons a (SCons 98 (SCons 99 (SCons b SNil))))
|
||||
|
@ -2,4 +2,4 @@
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/run_lazy/wrong_string.hvm
|
||||
---
|
||||
(SCons (*, 4) (SCons * ""))
|
||||
(SCons (*, 4) (SCons * SNil))
|
||||
|
Loading…
Reference in New Issue
Block a user