Repository navigation
Conversation
get_current_knot() returned hash_string("dead") rather than
hash_string("body.dead") for every stitch of a story's first-compiled
knot, and the full path for the stitches of every other knot. Which
form a caller got depended on where the knot fell in the alphabet.
start_container() files every child under indexed_children as well as
named_children, and every named child is filed at index -1. The map
keeps only the first, so each container's first named child is in both.
build_container_hash_map() walks named_children under the child's own
name, then walks indexed_children again under the parent's name, so
that one child's named children were hashed one level short and
overwrote the right _hash. At the root, that is the first knot: its
stitches came out as bare names, and the container hash table gained
an entry for each bare name as well.
The indexed walk now skips a child that is also named, since it was
hashed in the named walk.
Found by recording get_current_knot() at every ending of 70 stories:
three reported hashes that matched no knot or stitch path, all
stitches of the alphabetically first knot. With the fix, every ending
of all 70 matches its full path.
Ink Proof ResultsThese results are obtained by running the Ink-Proof Testing Suite on the compiled binaries in this pull request.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
get_current_knot()names a stitch by its full path (hash_string("knot.stitch")), except in a story's first-compiled knot, where it returns the stitch's bare name (hash_string("stitch")). Compiled JSON objects come out with their keys sorted, so which form a caller gets depends on where the knot falls in the alphabet.MoveTo.inkalready shows it: after the story runs intoDialog.core,get_current_knot()ishash_string("core"), andmove_to(hash_string("core"))succeeds.Why
start_container()files every child inindexed_childrenas well as innamed_children, and every named child goes in at index-1. The map keeps only the first, so each container's first named child is in both maps.build_container_hash_map()walksnamed_childrenunder each child's own name, then walksindexed_childrenagain under the parent's name. For that one child, its named children are hashed one level short, and because the indexed walk runs second, the short hash overwrites the right_hash. At the root that child is the first knot: its stitches get bare names, and the container hash table gains an extra entry for each bare name.The fix
The indexed walk skips a child that is also named, since the named walk has already hashed it under its own name. Unnamed indexed children are walked as before.
Tests
inkcpp_test/MoveTo.cppusing the existingMoveTo.ink:get_current_knot()after reachingDialog.coreishash_string("Dialog.core"), andmove_to(hash_string("core"))now returns false. Both fail without the fix. (Tags.cppalready covers a stitch in a later knot,knot2.sub.).pre-commit-config.yaml.get_current_knot()at every ending of 70 real stories. Before the fix, three stories reported hashes that matched no knot or stitch path, all of them stitches of the alphabetically first knot. After it, every ending matches its full path, and every story's walk is otherwise unchanged.Note
This is separate from the issue mentioned in #176: named children of an unnamed indexed container are still hashed without the index. That is unchanged here.