Skip to content

namely('alias') throws exception if not referenced once? #85

Open

Description

@Xmatik

From your example in the Readme (on the namely('alias') section)

If "self" reference is replaced in the parser it throws an error on compiling
=> Uncaught TypeError: Cannot set property 'resolved' of undefined

Example:
// the line below registers the name 'self', so we will be able to use it in // twoCells` as a reference
var parser = Parser.start().namely("self");

var stop = Parser.start().namely("stop");

var twoCells = Parser.start()
.namely("twoCells")
.nest("left", { type: "self" })
.nest("right", { type: "stop" });

parser.uint8("type").choice("data", {
tag: "type",
choices: {
0: "stop", // !!! replaced "self" with "stop"
1: "stop",
2: "twoCells"
}
});

var buffer = Buffer.from([2, /* left / 1, 1, 0, / right */ 0]);

parser.parse(buffer);`

Activity

  1. iabxhtk commented on Sep 25, 2020

    @iabxhtk

    Seems to be there still, when you call namely on a parser and compile it it throws the same error, the
    Context.prototype.markResolved = function (alias) { this.references[alias].resolved = true; };

    this.references[alias] is undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions