Closed Bug 653985 Opened 14 years ago Closed 7 years ago

multiple evals of definitions.consts in rhino causes error

Categories

(Other Applications Graveyard :: Narcissus, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: micmath, Unassigned)

References

()

Details

User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1 Build Identifier: Github Tree: 92f0a89 The following line appears near the top of several of Narcissus' library files (like jslex.js and jsparse.js, etc): eval(definitions.consts); When running under rhino this causes the following error: "TypeError: redeclaration of var END." Replacing that line with the equivalent const declarations, shown below, solves the problem. The difference is (I think) that the eval versions are all globally scoped in rhino, and therefore the constants get redeclared in the same scope whenever more than one of the library files are are evaluated. const END = 0, NEWLINE = 1, SEMICOLON = 2, COMMA = 3, ASSIGN = 4, HOOK = 5, COLON = 6, CONDITIONAL = 7, OR = 8, AND = 9, BITWISE_OR = 10, BITWISE_XOR = 11, BITWISE_AND = 12, EQ = 13, NE = 14, STRICT_EQ = 15, STRICT_NE = 16, LT = 17, LE = 18, GE = 19, GT = 20, LSH = 21, RSH = 22, URSH = 23, PLUS = 24, MINUS = 25, MUL = 26, DIV = 27, MOD = 28, NOT = 29, BITWISE_NOT = 30, UNARY_PLUS = 31, UNARY_MINUS = 32, INCREMENT = 33, DECREMENT = 34, DOT = 35, LEFT_BRACKET = 36, RIGHT_BRACKET = 37, LEFT_CURLY = 38, RIGHT_CURLY = 39, LEFT_PAREN = 40, RIGHT_PAREN = 41, SCRIPT = 42, BLOCK = 43, LABEL = 44, FOR_IN = 45, CALL = 46, NEW_WITH_ARGS = 47, INDEX = 48, ARRAY_INIT = 49, OBJECT_INIT = 50, PROPERTY_INIT = 51, GETTER = 52, SETTER = 53, GROUP = 54, LIST = 55, LET_BLOCK = 56, ARRAY_COMP = 57, GENERATOR = 58, COMP_TAIL = 59, IDENTIFIER = 60, NUMBER = 61, STRING = 62, REGEXP = 63, BREAK = 64, CASE = 65, CATCH = 66, CONST = 67, CONTINUE = 68, DEBUGGER = 69, DEFAULT = 70, DELETE = 71, DO = 72, ELSE = 73, EXPORT = 74, FALSE = 75, FINALLY = 76, FOR = 77, FUNCTION = 78, IF = 79, IMPORT = 80, IN = 81, INSTANCEOF = 82, LET = 83, MODULE = 84, NEW = 85, NULL = 86, RETURN = 87, SWITCH = 88, THIS = 89, THROW = 90, TRUE = 91, TRY = 92, TYPEOF = 93, VAR = 94, VOID = 95, YIELD = 96, WHILE = 97, WITH = 98; Reproducible: Always Steps to Reproduce: 1. Create a script that includes Narcissus and try to run it in rhino. 2. java -classpath js.jar org.mozilla.javascript.tools.shell.Main main.js 3. Actual Results: ./node_modules/narcissus/lib/jslex.js: new InternalError("TypeError: redeclaration of var END.") Expected Results: The constants should be declared in the local scope of the enclosing function, but eval() forces them to be declared in the global scope instead. I realise that Narcissus is not intended to be run under rhino, but it appears it can be (nearly) and would be very useful to projects like mine that I want to be runnable under more than one JS engine.
Closing as Narcissus isn't maintained anymore.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
Product: Other Applications → Other Applications Graveyard
You need to log in before you can comment on or make changes to this bug.