mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-11-05 04:51:40 +03:00
Return readback error for nested strings
This commit is contained in:
parent
46abc67967
commit
379414aa36
@ -272,15 +272,21 @@ impl<'a> Reader<'a> {
|
||||
let mut s = String::new();
|
||||
fn go(t: &mut Term, s: &mut String, rd: &mut Reader<'_>) {
|
||||
match t {
|
||||
Term::Num { val } => s.push(unsafe { char::from_u32_unchecked(*val as u32) }),
|
||||
Term::Lam { bod, .. } => go(bod, s, rd),
|
||||
Term::App { tag, arg, .. } if *tag == Tag::string_scons_head() => go(arg, s, rd),
|
||||
Term::App { tag, arg, .. } if *tag == Tag::string_scons_head() => {
|
||||
if let Term::Num { val } = &**arg {
|
||||
s.push(unsafe { char::from_u32_unchecked(*val as u32) });
|
||||
} else {
|
||||
rd.error(ReadbackError::InvalidStrTerm)
|
||||
}
|
||||
}
|
||||
Term::App { fun, arg, .. } => {
|
||||
go(fun, s, rd);
|
||||
go(arg, s, rd);
|
||||
}
|
||||
Term::Var { .. } => {}
|
||||
Term::Chn { .. }
|
||||
| Term::Num { .. } // expected to appear only inside SCons.head
|
||||
| Term::Lnk { .. }
|
||||
| Term::Let { .. }
|
||||
| Term::Tup { .. }
|
||||
|
1
tests/golden_tests/run_file/nested_str.hvm
Normal file
1
tests/golden_tests/run_file/nested_str.hvm
Normal file
@ -0,0 +1 @@
|
||||
Main = (SCons "a" SNil)
|
6
tests/snapshots/run_file__nested_str.hvm.snap
Normal file
6
tests/snapshots/run_file__nested_str.hvm.snap
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/run_file/nested_str.hvm
|
||||
---
|
||||
Invalid readback: [InvalidStrTerm]
|
||||
""
|
Loading…
Reference in New Issue
Block a user