Skip to content

Nil - can't locate function name #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
deandob opened this issue Jul 26, 2018 · 5 comments
Closed

Nil - can't locate function name #57

deandob opened this issue Jul 26, 2018 · 5 comments

Comments

@deandob
Copy link

deandob commented Jul 26, 2018

Hi,

I'm trying to use JavaScriptEngineSwitcher for the NiL JS engine as it is the best fit for my use-case, however it seems there is an issue with being able to call functions, with the switcher reporting JavaScriptEngineSwitcher.Core.JsRuntimeException: 'The function with the name 'negate' does not exist.'
yet when I run exactly the same code with Jint it works fine. Is the NiL wrapper not ready for use? The code is from your test cases, as below:

` JsEngineSwitcher engineSwitcher = (JsEngineSwitcher)JsEngineSwitcher.Current;
engineSwitcher.EngineFactories
.AddNiL(new NiLSettings
{
StrictMode = true
})
//.AddJint()
//.AddJurassic()
//.AddMsie(new MsieSettings
//{
// UseEcmaScript5Polyfill = true,
// UseJson2Library = true
//})
//.AddV8()
;

        engineSwitcher.DefaultEngineName = NiLJsEngine.EngineName;
        //engineSwitcher.DefaultEngineName = JintJsEngine.EngineName;

        const string functionCode = @"function negate(value) {
            return -1 * value;
        }";
        using (var engine = JsEngineSwitcher.Current.CreateDefaultEngine())
        {
            try
            {
                engine.Execute(functionCode);
                var result = engine.CallFunction("negate", 22);         //<=== Error here with NiL, function 'negate' not found, OK with Jint
            }
            catch (TimeoutException)
            {
                Console.WriteLine("Timed out!");
            }`
@Taritsyn
Copy link
Owner

Hello, Dean!

It seems, that this is some kind of error in the NiL.JS, because it occurs only in strict mode. I created a issue in repository of the original project - nilproject/NiL.JS#146

@deandob
Copy link
Author

deandob commented Jul 26, 2018

Yep, that's it! Thanks for the quick response, and thanks for JSEngineSwitcher, very helpful.

@Taritsyn
Copy link
Owner

By the way, instead of the TimeoutException class you need to use the JsTimeoutException and timeouts occur only in the JavaScriptEngineSwitcher.Jint module.

@deandob
Copy link
Author

deandob commented Jul 27, 2018

OK. Thx. I'll close this now.

@deandob deandob closed this as completed Jul 27, 2018
Taritsyn added a commit that referenced this issue Aug 16, 2018
@Taritsyn
Copy link
Owner

Hello, Dean!

This error is fixed in version 3.0.0 Beta 9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants