sebastienros / jint

Javascript Interpreter for .NET
BSD 2-Clause "Simplified" License
4.1k stars 563 forks source link

Unable to sort because the IComparer.Compare() method returns inconsistent results on Typograf lib #1789

Closed nktdrkhv closed 8 months ago

nktdrkhv commented 8 months ago

3.0.0 (same problem with 2.11.58)

Description

It's getting System.ArgumentException: Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results. while trying to invoke a test funtion. err.txt

To Reproduce

Create a regular console app. Typograf is a Typescript lib which I got with npm install typograf and then copied typograg.js from node-modules/typograf/dist/typograf.js

using Jint;
var engine = new Engine();
engine.Execute(File.ReadAllText("typograf.js"));
engine.Execute("""
function test() {
    var tp = new Typograf({locale: ['ru', 'en-US']});
    return tp.execute('"Привет мир - привет!..."');
}
""");
Console.WriteLine(engine.Invoke("test"));

Expected behavior

Printing: «Привет мир — привет!..»

Additional context

I tried different ways to import and use a module but result is the same With JSEngineSwitcher too

scgm0 commented 8 months ago

Looks like the same problem as #1028

lahma commented 8 months ago

I'll close this as there's existing issue and we need to wait for a PR.

nktdrkhv commented 8 months ago

Btw, for those who are also faced with this problem and want to find at least a temporary solution. Jurassic and Yantra.JS also failed to launch the Typograf, but the NiL.JS can.

lahma commented 8 months ago

NiL.JS is a wonderful project, it's very performant and handles common flow very well, deviates sometimes from the JS spec a bit though.