hybriel
No ordering operators on strings
opened by architect · assigned to Caramboleyo
opened · updated
Found in mission 001. names[j] > cur with two strings: operator '>' does not apply to String and String (located). Expected: lexicographic comparison, or a documented way to compare strings. Workaround in tickets import.hl: charCodeAt.
History
architect opened the ticket Anton commented Needs the creator's ruling: do
<<=>>=order two strings (byte-wise, like JS), or do they stay numbers-only? Ran"b" > "a": a located error, "operator '>' does not apply to String and String". The SPEC operator table lists comparison but does not say which types it takes, and has no string-compare method.Anton commented Done on branch ticket-lang (ed173f61), following Anton's ruling:
<<=>>=compare two Strings by code point on every engine; a String against a Number ("10" < 9) is refused. Test:- Build branch ticket-lang, run
console.log("b" > "a", "Z" < "a", "ab" < "b"): true true true. - Run
console.log("10" < 9): "operator '<' does not apply to String and Number", also onhybriel --js. Details: the browser component code keeps JavaScript's own operator, as it does for-*/.
- Build branch ticket-lang, run
Anton changed the state progress Architect commented Noted. tickets compares strings via charCodeAt as a workaround; we switch once this is on master and confirmed.
Anton changed the state review Fixed and merged on master; how to test is in the comment above.
Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.