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

"TypeError: v is null" when parsing numbers with exponent #44

Open
h3ndrk opened this issue Jan 5, 2020 · 0 comments
Open

"TypeError: v is null" when parsing numbers with exponent #44

h3ndrk opened this issue Jan 5, 2020 · 0 comments

Comments

@h3ndrk
Copy link

h3ndrk commented Jan 5, 2020

Thanks for the great library! I found a bug in the graph writer:

Consider a graph with a node attribute x=-1.4703333520951247e-16, when writing and reading the same graph, graphlib-dot yields TypeError: v is null in peg$c34:

var dot = require('graphlib-dot');
var graphlib = require('graphlib');

// prepare graph
var graph = new graphlib.Graph({directed: false});
graph.setNode(42, { x: -1.4703333520951247e-16 });

// show output
dot.write(graph); // -> 'strict graph {\n  "42" [x=-1.4703333520951247e-16]\n}\n'

// trigger TypeError
dot.read(dot.write(graph));
// Uncaught TypeError: Cannot read property '3' of null
//     at peg$c34 (node_modules/graphlib-dot/lib/dot-grammar.js:114:28)
//     at peg$parseidDef (node_modules/graphlib-dot/lib/dot-grammar.js:1421:16)
//     at peg$parseaList (node_modules/graphlib-dot/lib/dot-grammar.js:1173:20)
//     at peg$parseattrListBlock (node_modules/graphlib-dot/lib/dot-grammar.js:1093:16)
//     at peg$parseattrList (node_modules/graphlib-dot/lib/dot-grammar.js:1012:12)
//     at peg$parsenodeStmt (node_modules/graphlib-dot/lib/dot-grammar.js:808:16)
//     at peg$parsestmt (node_modules/graphlib-dot/lib/dot-grammar.js:689:20)
//     at peg$parsestmtList (node_modules/graphlib-dot/lib/dot-grammar.js:538:12)
//     at peg$parsegraphStmt (node_modules/graphlib-dot/lib/dot-grammar.js:452:28)
//     at Object.parse (node_modules/graphlib-dot/lib/dot-grammar.js:2372:18)

I think dot.write() produces a non-compliant string (because the ID is not allowed to have a dash -). The parser looks fine.

I'm using graphlib-dot@0.6.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant