Subj : Spidermonkey: error with const on second run of script To : netscape.public.mozilla.jseng From : Peter Paulus Date : Wed Jul 23 2003 05:56 pm Hello all, In own of my test-javascripts I'm using the line: const engine = Engine.getEngine(); // get first registered engine Engine is a custom class (JSClass) that I've build. When I run this script for the first time all seems to be okay. When I run the same script for the second time I get an error that a const variable is redefined. Here's the code that runs the script (C++ wrapper around Spidermonkey) void Context::runScriptFile(const char* source) { jsval result; JSScript* script = JS_CompileFile(context, globalObj, source); if (script) { JSBool ok = JS_ExecuteScript(context, globalObj, script, &result); if (ok == JS_FALSE) { _STD::cout << "error in Context::runScriptFile()" << _STD::endl; } JS_DestroyScript(context, script); } } The context is not destroyed. How can I prevent this error? I'm not quit sure if I've handled the context right. When I create the JS_Runtime, I also create 1 JS_Context. This context is destroyed when the JS_Runtime is destroyed. With kind regards, Peter Paulus .