Hi. I made a patch with tests to fix this issue.
We must set the indent level correctly even if there are no more lines.
diff --git a/lib/YAML/Loader.pm b/lib/YAML/Loader.pm
index 321293d..53f4830 100644
--- a/lib/YAML/Loader.pm
+++ b/lib/YAML/Loader.pm
@@ -630,7 +630,10 @@ sub _parse_next_line {
$self->die('YAML_EMIT_ERR_BAD_LEVEL') unless defined $offset;
shift @{$self->lines};
$self->eos($self->{done} = not @{$self->lines});
- return if $self->eos;
+ if ($self->eos) {
+ $self->offset->[$level + 1] = $offset + 1;
+ return;
+ }
$self->{line}++;
# Determine the offset for a new leaf node
diff --git a/t/load-works.t b/t/load-works.t
index fafb931..f6dcd1c 100644
--- a/t/load-works.t
+++ b/t/load-works.t
@@ -14,3 +14,9 @@ __DATA__
+++ yaml
---
foo: bar
+=== empty hashes
++++ perl
++{foo1 => undef, foo2 => undef}
++++ yaml
+foo1:
+foo2:
https://rt.cpan.org/Ticket/Display.html?id=82877