Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #325 - null simple keys not properly nullified #327

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions source/dyaml/loader.d
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,8 @@ EOS";
auto e = loader.load().collectException!ScannerException(unused);
assert(e.mark.name == filename);
}
/// https://github.com/dlang-community/D-YAML/issues/325
@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