Skip to content

Commit

Permalink
fix dlang-community#325 - null simple keys not properly nullified
Browse files Browse the repository at this point in the history
  • Loading branch information
Herringway committed Oct 5, 2023
1 parent 4196fb8 commit 62a631e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions source/dyaml/loader.d
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,7 @@ EOS";
auto e = loader.load().collectException!ScannerException(unused);
assert(e.mark.name == filename);
}
@safe unittest
{
assert(Loader.fromString("--- {x: a}").load()["x"] == "a");
}
7 changes: 5 additions & 2 deletions source/dyaml/scanner.d
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,11 @@ struct Scanner
{
const oldLength = possibleSimpleKeys_.length;
possibleSimpleKeys_.length = flowLevel_ + 1;
//No need to initialize the last element, it's already done in the next line.
possibleSimpleKeys_[oldLength .. flowLevel_] = SimpleKey.init;
// Make sure all the empty keys are null
foreach (ref emptyKey; possibleSimpleKeys_[oldLength .. flowLevel_])
{
emptyKey.isNull = true;
}
}
possibleSimpleKeys_[flowLevel_] = key;
}
Expand Down

0 comments on commit 62a631e

Please sign in to comment.