git.delta.rocks / jrsonnet / refs/commits / 830d8fba206a

difftreelog

fix yaml stream handling difference

nwkyuspoYaroslav Bolyukin2026-04-25parent: #a486673.patch.diff
in: master

1 file changed

modifiedcrates/jrsonnet-stdlib/src/parse.rsdiffbeforeafterboth
99
10#[builtin]10#[builtin]
11pub fn builtin_parse_yaml(str: IStr) -> Result<Val> {11pub fn builtin_parse_yaml(str: IStr) -> Result<Val> {
12 let needs_synthetic_null = str.trim_end().ends_with("\n---");
13
12 let out = serde_saphyr::from_multiple_with_options::<Val>(14 let mut out = serde_saphyr::from_multiple_with_options::<Val>(
13 &str,15 &str,
14 serde_saphyr::Options {16 serde_saphyr::Options {
15 // Golang/C++ compat17 // Golang/C++ compat
21 )23 )
22 .map_err(|e| runtime_error!("failed to parse yaml: {e}"))?;24 .map_err(|e| runtime_error!("failed to parse yaml: {e}"))?;
25
26 // saphyr and other yaml implementations disagree on how to handle an empty document in multi-document stream.
27 // Saphyr only considers document started after anything is emitted after the document delimiter
28 if needs_synthetic_null {
29 out.push(Val::Null);
30 }
31
23 Ok(if out.is_empty() {32 Ok(if out.is_empty() {
24 Val::Null33 Val::Null