Don't use "objects" in lib/compiler/passes/report-duplicate-labels.js

The "objects" module will be removed.

See #442.
redux
David Majda 8 years ago
parent d2569b9bf3
commit 76e70c3923

@ -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));
});
},

Loading…
Cancel
Save