jscert / jsexplain

Apache License 2.0
26 stars 4 forks source link

Lexicographical String Orderings Broken #1

Closed IgnoredAmbience closed 7 years ago

IgnoredAmbience commented 7 years ago

"x" < "" returns true 😒 https://psvg.doc.ic.ac.uk/ci/jscert-testing/test/6140650 https://github.com/tc39/test262/blob/29e247ddd45a148f56be70b3d7120b7c5e649926/test/suite/ch11/11.8/11.8.1/S11.8.1_A4.10.js

This bug appears to be causing most of the regressions between jsref and mljsref.

brabalan commented 7 years ago

On 2016-11-07 10:46, Thomas Wood notifications@github.com writes:

"x" < "" returns true 😒

This is strange, it returns false in ocaml. We agree that it should return false in JS as well?

Looking at jsinterpreter.ml, the problem is clear:

let inequality_test_string s1 s2 = (not (string_eq s1 s2))

This code should test prefix instead. (The corresponding code for numbers does the right thing.) By the way, looking at the spec https://es5.github.io/#x11.8.5 we can either say this is what "<" does in OCaml, or start looking at the notion of “code unit value for character”, which opens up the Unicode Pandora box.

https://psvg.doc.ic.ac.uk/ci/jscert-testing/test/6140650

I need to login to see this.

https://github.com/tc39/test262/blob/29e247ddd45a148f56be70b3d7120b7c5e649926/test/suite/ch11/11.8/11.8.1/S11.8.1_A4.10.js

This bug appears to be causing most of the regressions between jsref and mljsref.

I take this as good news 😉

Alan

OpenPGP Key ID : 040D0A3B4ED2E5C7 Monthly Athmospheric CO₂, Mauna Loa Obs. 2016-09: 401.03, 2015-09: 397.63

sergiomaffeis commented 7 years ago

hi,

On 08/11/2016 08:23, Alan Schmitt wrote:

On 2016-11-07 10:46, Thomas Wood notifications@github.com writes:

"x" < "" returns true 😒

This is strange, it returns false in ocaml. We agree that it should return false in JS as well?

in js it should return false. it's basically lexicographic order on strings.

Looking at jsinterpreter.ml, the problem is clear:

let inequality_test_string s1 s2 = (not (string_eq s1 s2))

This code should test prefix instead. (The corresponding code for numbers does the right thing.) By the way, looking at the spec https://es5.github.io/#x11.8.5 we can either say this is what "<" does in OCaml, or start looking at the notion of “code unit value for character”, which opens up the Unicode Pandora box.

https://psvg.doc.ic.ac.uk/ci/jscert-testing/test/6140650

I need to login to see this.

https://github.com/tc39/test262/blob/29e247ddd45a148f56be70b3d7120b7c5e649926/test/suite/ch11/11.8/11.8.1/S11.8.1_A4.10.js

This bug appears to be causing most of the regressions between jsref and mljsref.

I take this as good news 😉

Alan

OpenPGP Key ID : 040D0A3B4ED2E5C7 Monthly Athmospheric CO₂, Mauna Loa Obs. 2016-09: 401.03, 2015-09: 397.63

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jscert/jsexplain/issues/1#issuecomment-259074307, or mute the thread https://github.com/notifications/unsubscribe-auth/AEhEzHAgsgsx3lBpnJreZ0njAGa2R5Vzks5q8DGbgaJpZM4KrkdB.

brabalan commented 7 years ago

Note: there is no need to fix this in jsref, as it's using (correct) extracted code: https://github.com/jscert/jscert/blob/master/coq/JsPreliminary.v#L179