From 3e258c5d9d3ed66bd52303ec5f18933f1b76769a Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sat, 24 Aug 2019 01:46:11 +0800 Subject: [PATCH] avoid hashCode == 0 --- runtime/JavaScript/src/antlr4/PredictionContext.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/JavaScript/src/antlr4/PredictionContext.js b/runtime/JavaScript/src/antlr4/PredictionContext.js index e69cdea37..8b2e2ece0 100644 --- a/runtime/JavaScript/src/antlr4/PredictionContext.js +++ b/runtime/JavaScript/src/antlr4/PredictionContext.js @@ -111,11 +111,13 @@ Object.defineProperty(PredictionContextCache.prototype, "length", { function SingletonPredictionContext(parent, returnState) { var hashCode = 0; + var hash = new Hash(); if(parent !== null) { - var hash = new Hash(); hash.update(parent, returnState); - hashCode = hash.finish(); + } else { + hash.update(1); } + hashCode = hash.finish(); PredictionContext.call(this, hashCode); this.parentCtx = parent; this.returnState = returnState;