From 76e70c3923c13e2c21a9f24d274bdc82379b7825 Mon Sep 17 00:00:00 2001 From: David Majda Date: Wed, 14 Sep 2016 13:48:12 +0200 Subject: [PATCH] Don't use "objects" in lib/compiler/passes/report-duplicate-labels.js The "objects" module will be removed. See #442. --- lib/compiler/passes/report-duplicate-labels.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/compiler/passes/report-duplicate-labels.js b/lib/compiler/passes/report-duplicate-labels.js index a027bd9..7614594 100644 --- a/lib/compiler/passes/report-duplicate-labels.js +++ b/lib/compiler/passes/report-duplicate-labels.js @@ -1,13 +1,22 @@ "use strict"; let GrammarError = require("../../grammar-error"), - objects = require("../../utils/objects"), visitor = require("../visitor"); /* Checks that each label is defined only once within each scope. */ function reportDuplicateLabels(ast) { + function cloneEnv(env) { + let clone = {}; + + Object.keys(env).forEach(name => { + clone[name] = env[name]; + }); + + return clone; + } + function checkExpressionWithClonedEnv(node, env) { - check(node.expression, objects.clone(env)); + check(node.expression, cloneEnv(env)); } let check = visitor.build({ @@ -17,7 +26,7 @@ function reportDuplicateLabels(ast) { choice: function(node, env) { node.alternatives.forEach(alternative => { - check(alternative, objects.clone(env)); + check(alternative, cloneEnv(env)); }); },